2

I'm using PHP to allow a user to upload a file. The file is being uploaded, but the permissions on the file are incorrect. I set up the permissions on the folder and checked the box that says apply to all children in the folder.

This works only after I make one change to the newly uploaded file. If I don't make a change to the permissions, it gets this default set that breaks the rest of my application.

For example, C:\uploads\ is set to allow users in the group "Everyone" to read and write. This however doesn't apply to the newly uploaded file until I do something to that specific file's permissions (add or remove any user or group to its permissions - this change gets overwritten by the folder's permissions).

This is on IIS6 (I believe) on Windows Server 2003

Trim
  • 375
  • 1
  • 5
  • 14

2 Answers2

2

Windows upload file to temp directory and then move it with temp directory permissions. If You give good permissions to the user on this folder (upload_tmp_dir) then will be no problem. You can also use windows system command: CACLS or ICACLS

Daimos
  • 1,473
  • 10
  • 28
  • Brilliant! I would not have guessed this in a million years. In my case, users were uploading image files to MediaWiki, which uses PHP. The resulting permissions for the file did not include the windows security group that was required for other users to be able to see the newly uploaded files. As Daimos suggested, I added that security group to the "%SystemRoot%\Temp" directory and solved the problem. – David Rogers Apr 16 '15 at 18:32
0

Do:

chmod()

On Your file after upload

Daimos
  • 1,473
  • 10
  • 28