I am facing a strange issue with a managed_file field in my Drupal form API. Whenever I upload a file and save the form, and then come back again to upload another file with the same name, I get this error message.
The specified file xyz.png could not be uploaded. The file temporary://xyz.png already exists. Enter a unique file URI.
However, if I try to upload the file again, it gets uploaded successfully with the file name renamed.
I noticed a similar issue reported in the module issue queue.
Can anyone suggest why this might be happening and how to fix it?