Jump to content

PHP File uploads [aka: Using umask]


mattcairns

Recommended Posts

Ok, first off thanks in advance to anyone who takes a look at this. I am very stuck. Now onto the problem...

 

I am transferring an admin from the server it was developed to the server where it will be hosted. On this new server I am having permission issues. If I change the permission of the target directory to 0777 (using my ftp program),  I can upload the file to that directory. The file uploads with it's permission set to 0511, by default (I assume as I am not setting it anywhere). Now the problem is deleting or overwriting the file. I try to change the permission on the file to 0777 to delete or overwrite it using chmod with no luck. Safe mode is off on the new server so to the best of my knowledge the problem is most likely the user or group settings. After hours of research I came across what I thought could be the solution, "umask". I've tried this unsuccessfully a number of ways. So I guess the question is how would I use umask, and if umask is even a solution. Thank you again for looking into this. Below is my upload code for refrence, without using umask.

 

chmod("$uploaded_file_dir/$dest/$saveFile", octdec(0777));
if(rename($_FILES[files][tmp_name][$keys[$i]], "$uploaded_file_dir/$dest/$saveFile")){
   chmod("$uploaded_file_dir/$dest/$saveFile", octdec(0777));
}else{
   die("Could not upload $uploaded_file_dir/$dest/$saveFile");
}

Link to comment
https://forums.phpfreaks.com/topic/41466-php-file-uploads-aka-using-umask/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.