How to rename a file uploaded via a managed file widget on a custom form if the filename exists already?
We have a Drupal 9 website with a managed file field on a custom form where the user is getting an error that the file name already exists (if it does).
How can we automatically rename the file if it exists?
Also, we’d like to clean the file names, remove spaces and non-standard characters.
This is a screenshot of the managed file field on our custom form.

This article was republished from its original source.
Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.