Opencart and PHP running on IIS, we found Permissions incorrect on uploaded files
After working with IIS server running PHP, we found the files uploaded through the web interface of the opencart CMS failed to inherit the correct permissions.
After spending weeks time to resolve this problem, believing that it was a glitch that required file permissions to be reset we found an easy solution.
The problem lies with the PHP system running on IIS. When you use a web interface to upload files to your PHP CMS website, they are initially loaded to the PHP defined temporary folder. The temporary folder is set in the PHP.ini file.
To find this file and check the setting, you do this:
Open IIS and select PHP Manager
Then Check phpinfo()
Then search the php.ini file that opens for “upload_tmp_dir”
Notice that the default location (unless you have changed it) is: c:\windows\temp
Now navigate to that folder on your IIS server rick click and select Properties / Security Tab and find the IIS_IUSRS security group.
Edit the permissions there to match the permissions of your IIS website folder that is causing you the grief. Probably Read Write at least is needed.
Why the solution works.
As files are uploaded through the website interface, they land in the temp directory. Once there they inherit the temp directory permissions before being moved onto the website folders. By adding the website security to the temp folder, you allow the files to move across with the correct permissions set.
This would be applicable for WordPress running on IIS server, or Opencart.
WordPress 3.5 Manual Fix
Below is the manual fix you can apply to be able to get your WordPress 3.5 install working correctly, there are two options that should work.
1) In the file wp-config.php, add the following line before “That’s all, stop editing”
define( 'WP_TEMP_DIR', ABSPATH . 'wp-content/' );
2) In the file /wp-includes/class-http.php comment out lines 144 and 145, which look like the following:
if ( ! is_writable( dirname( $r['filename'] ) ) )
return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
After applying one of the above fixes you should be able to add/upgrade your plugins and upgrade your themes, and will allow you to use the auto upgrade feature when WordPress version 3.5.1 is released.