Web Hosting Talk







View Full Version : PHP permission settings


That Guy
03-03-2005, 03:45 AM
I'm creating a script, and one of its functions is to delete a file. I have set the permission of the folder to 777. When I try and unlink() the file, I get a permission denied error. I suspect it's because of the file's permissions. I tried to change them via chmod() but I got another permission denied. I know I could just change it from my side instead of using a script, but it's an upload script and obviously the user doesn't have access from my side. Could anyone tell me a way to change file permissions so I can delete a file?

Burhan
03-03-2005, 04:05 AM
You have a few options here :

1. suexec (phpsuexec) to run the script as a different user.
2. setup a cron job that changes permissions on the files to something that your script can delete.
3. modify the apache configuration so that files saved by the apache user (which is what the php script runs as) have permissions that allow you to delete them.

That Guy
03-03-2005, 11:33 AM
Ok, thanks. :) I guess I'll do a little research on those.