When I try to upload a file with a file field, Drupal creates a sites/default/files/2023-10 directory, but can't upload the file. I see this validation error in the UI: "File upload error. Could not move uploaded file." And I see a similar notice in the Drupal log: "Upload error. Could not move uploaded file test.txt to destination public://2023-10/test.txt."

In admin/config/media/file-system, my public file system path is set to sites/default/files. There are no errors on the status page indicating a permissions problem.

If I delete the files directory altogether, and then save the form at admin/config/media/file-system, Drupal creates sites/default/files and sites/default/files/php.

What are the possible reasons Drupal can create directories inside of sites/default/files, but can't upload files?

Drupal version: 9.5.11
Web server: IIS 10
PHP 8.1.21
  • Is there any specific error you are getting while upload files in the logs either in console, try to upload file of smaller size like 2MB may be issue of file size larger
    – mini
    Oct 26, 2023 at 14:14
  • A possible reason is that whatever user context IIS or Drupal is running in can create directories but not files. I don't think we can give a fact-based acceptable answer without information from you as to what the filesystem permissions actually are.
    – cilefen
    Oct 26, 2023 at 14:16
  • @mini The file size isn't the issue. I updated the ticket with the notice I'm seeing in the log, though it is similar to the validation error displayed in the UI.
    – arnoldbird
    Oct 26, 2023 at 15:13
  • 2
    Please be aware of drupal.org/project/drupal/issues/3358248
    – cilefen
    Oct 26, 2023 at 15:49
  • 1
    Windows filesystem has no concept of 777 AFAIK.
    – cilefen
    Oct 26, 2023 at 17:03

1 Answer 1


I needed to set the upload_tmp_dir in PHP.ini. This is what worked for me:

upload_tmp_dir = c:\PHP\tmp

I also gave full permissions to the IUSR user for that directory.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.