View Full Version : PHP Upload file permission problems.

10-09-2003, 10:35 PM
Guys/gals got a good one for you.

Im using a PHP upload script that was previously working flawlessly. My host moved me to another server and now for some reason when i do a php file upload it assignes the file permissions: 600 and owner gets set to 99. Im not sure what eh owner was set to previously when it was working before the site move, however i do know that permissions were set to: 644 by default when it was uploaded.

The real problem is that a good deal of my site users cannot see their files when the permissions are set to 600, the get forbidden errors. Additionally i cant change the permissions back to 655, 777, 644 or anything. The only thing i can do is delete the file. I cant even download it through ftp.

So my question is: Is there an apache setting that could affect this that might be different from my original server thats causing this problem? Its become a headache for me and i would like to get it resolved... Any ideas?

10-10-2003, 12:49 PM
when you say you can't change the permissions .. how are you trying ? via script / SSH / FTP ?

when you upload a file it should be 'owned' by apache ( usually 'nobody' ) and you should be able to chmod the file via script eg

<?php chmod( $uploaded_file , 0644 );?>

if you can't do that via script then apart from anything else...its weird and I would suggest an email to your host as they probably had something to do with it !

(ps try creating the upload directory via script <?mkdir( $upload_dir , 0777 ) ;?> , and see if you have any more luck with that (& don't forget to chmod back to 0644 when finished doing stuff if you are on a shared host)

10-10-2003, 02:15 PM
Right, the file is owned by 'nobody' but the strange part about resetting the permissions on the file is that if i use FTP to do it, it gives access is denied. If i try to do it through CPANEL it says access denied. However if i use the file upload thats apart of CPANEL it uploads with the correct permissions AND i can also change the permissions ot the file. Its an extremely strange and aggrevating problem.

I spoke with the host yesterday about it and got him to reset the owner on the files so that i was owner and then corrected the permission problems, but we werent able to determine why it was doing this and not allowing me to change the permissions on the file after i uploaded them. Is this possibly a user rights problem?

btw, thanks for the input!