iPixel Posted June 8, 2010 Share Posted June 8, 2010 So i have this simple upload script, grabs a file and shoots it over to a folder on the server. The folders that the files get uploaded to have "Full Control" permission, but when the files get uploaded via this script, those permission do not carry over properly which give me a delete issue. Can anyone give me some pointers how i could force the file to automatically inherit all permissions that it's containing folder holds. script: // Where the file is going to be placed $target_dir = "Benefits/"; // Add the original filename to our target path. //Result is "uploads/filename.extension" $target_path = $target_dir . basename( $_FILES['thefile']['name']); if(move_uploaded_file($_FILES['thefile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['thefile']['name']). " has been uploaded to the Benefits/ folder."; } else { echo "There was an error uploading the file, please try again!"; } Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/204210-permission-inheritance-issue-upon-file-upload/ Share on other sites More sharing options...
dabaR Posted June 9, 2010 Share Posted June 9, 2010 Can you just use http://ca.php.net/manual/en/function.chmod.php ? Quote Link to comment https://forums.phpfreaks.com/topic/204210-permission-inheritance-issue-upon-file-upload/#findComment-1069768 Share on other sites More sharing options...
trq Posted June 9, 2010 Share Posted June 9, 2010 This has nothing to do with php. You'll want to look at the 'sticky bit' setting on the directories in question. Quote Link to comment https://forums.phpfreaks.com/topic/204210-permission-inheritance-issue-upon-file-upload/#findComment-1069774 Share on other sites More sharing options...
iPixel Posted June 9, 2010 Author Share Posted June 9, 2010 Well when i just upload a file via FTP the permissions work fine, it only happens when i pass it through the form. Quote Link to comment https://forums.phpfreaks.com/topic/204210-permission-inheritance-issue-upon-file-upload/#findComment-1069908 Share on other sites More sharing options...
iPixel Posted June 9, 2010 Author Share Posted June 9, 2010 I think i should mention exactly what the permission issue is. I ran a script to check all file permissions. substr(decoct(fileperms("Benefits/" . $file)),2); And they all turn out 0666 no matter how they were uploaded. However the ones that get uploaded via web form dont get "Everyone" in their securities tab, instead they get something called "Internet Guest Account"... but it need to get everyone i'm pretty sure in order to be allowed to delete the files. Quote Link to comment https://forums.phpfreaks.com/topic/204210-permission-inheritance-issue-upon-file-upload/#findComment-1069911 Share on other sites More sharing options...
iPixel Posted June 9, 2010 Author Share Posted June 9, 2010 ... Sorry bloody modify wont work, some sesssion verification issues, let me add to that, When uploaded through web form i get permissions as such Admin Internet Guest Account Network Service Power User System When uploaded normally via ftp, or directly into the folder on the server machine Admin Everyone Pt. Jefferson HR syxart iPixel Any idea why the file being uploaded gets totally different security groups and users? Quote Link to comment https://forums.phpfreaks.com/topic/204210-permission-inheritance-issue-upon-file-upload/#findComment-1069914 Share on other sites More sharing options...
iPixel Posted June 9, 2010 Author Share Posted June 9, 2010 Finally figured it out, all the folder permissions were set accurately except the c:windows/temp folder which was the temporary folder for uploaded files before they were moved to their final destination. I simply changed the upload_tmp_dir in php ini to a folder that held the same permissions as i needed them to and voila! it works! Bloody windows . Thanks 2 all . Quote Link to comment https://forums.phpfreaks.com/topic/204210-permission-inheritance-issue-upon-file-upload/#findComment-1069948 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.