File Permissions on Uploads - Windows Server 2008 R2

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 4, 2011   (RSS)

By garyhoffmann - May 3, 2011

Hello, I have a site that had been hosted on Linux without any issues, but due to the potential of needing some .Net development, they have opted to move to a Windows server.

This server runs Windows Server 2008 R2 Standard with the Plesk control panel, but we have access to Remote Desktop, so I can pretty much mess with anything I want on the system.

The problem with this system is that the permissions are set to allow full control on the uploads directory and it is set to propagate these permissions to all child objects, but whenever I upload a new file, it is not getting the ownership information the same as the parent folder.

This is happening on the main site as well as the development site which is really just a subdomain off the main domain.

Assume the main domain has a path of c:\sites\site, the development site has a path of c:\sites\site\dev

I have applied and re-applied the permissions, both through plesk and through the operating system directly and still have the same issue.

Any guidance would be appreciated.

Thanks,
Gary.

Re: [garyhoffmann] File Permissions on Uploads - Windows Server 2008 R2

By garyhoffmann - May 3, 2011

I rarely have the luck of finding my own answer as quickly as I did, even though quick is a relative term as I've been spending hours up to this point, but just after I posted the original message, I had a thought that the problem was coming from PHP instead of CMSB. I was able to manually create a file in the uploads directory no problem - it got the correct permissions.

But the problem was solved with this post I found on the web.

If you’re like me, and you use Windows IIS, you’ve spent hours trying to figure out why your uploaded file won’t inherit the permissions needed to display correctly. Luckily, the answer is extremely easy and something most people would have never thought of. The problem only happens when you use PHP to upload a file. When you upload a file, PHP sends the file to a temporary directory on the hard drive (for me it is C:\Windows\Temp) and then copies it over to it’s intended directory. Once the file has landed in the temporary directory, it is assigned the permissions of that directory. The problem is when Windows copies that file, it keeps the temporary directory’s permissions and doesn’t inherit your web directory’s permissions. The easiest way to fix this problem is to add to the temporary directory your intended web directory’s permissions. In other words, don’t erase the permissions already in the temporary directory, just add the web directory’s permissions to them. If you want to change your temporary upload directory, find the “upload_tmp_dir” in your php.ini file and set it to the directory of your choosing (outside your web folders of course), and then add the proper permissions. And just so you know, if the two folders were on separate drives, you wouldn’t have this problem, and thus wouldn’t be reading this. So as you can see, its really simple and just a little trick the guys at PHP forgot to tell us.

To give credit where credit is due:

http://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/

Re: [garyhoffmann] File Permissions on Uploads - Windows Server 2008 R2

By Damon - May 4, 2011

Hi Gary,

Glad to hear you were able to solve the Windows file permissions issue.

And thanks for that link to a fix. I have added that to my Favorites to have for quick reference if this issue comes up again in the forum.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/