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?

  • I think you indicated that you have a custom code implementation. If you do we need to see that in order to answer your question.
    – cilefen
    Mar 31, 2023 at 12:39
  • Added my code here - github.com/zuhairkareem/form_api-test , this is multistep form, step 1 there is managed_file, file stored in temporary folder, Step2 - get name & emal, on Submit- move file from temporary folder to Public folder, I think the issue is due to moving from temporary folder to public folder in step 2.
    – Zuhair
    Apr 2, 2023 at 12:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.