WordPress: image upload error on Windows Server 2012, 2016

After installing a new WordPress web site on Windows Server 2012 or 2016 we usually have issues with media library function “upload” or having problems simply showing an uploaded images. By default you can’t upload images and get error messages like “File error occurred” or “The uploaded file could not be moved to ….\wp-content\uploads”.

Recommended steps

1. Give the IUSR account write/modify permissions for the …\wp-content\uploads directory and its subdirectories.

2. Adjust PHP Temporary folder when you experience inheritence errors. When we upload a file to the server, PHP saves the file to a temporary directory like as C:\Windows\Temp before copying it to the web site’s …\wp-content\uploads folder. Files are given the read/write and owner permissions of that directory. Windows keeps the temporary directory’s permissions and doesn’t inherit our web directory’s permissions while copying these files to our folder. That may be a problem. You can change PHP’s “upload_tmp_dir” settings in your php.ini file to a directory of your choosing. Select another driver (like D:/temp) or a new folder outside the focus of your web sites and give the proper IUSR read/write access rights to it.

3. When all above is not enough, open IIS manager and select your site. Find IIS group and Authenticate action. Edit Anonymous Authentication. In the Anonymous Authentication Credientials set identity to “Application pool identity”.

wordpress upload error to media library, images, video, audio files