Dman8568 Posted June 14, 2006 Posted June 14, 2006 I am currently writing a file management service, in PHP, for my website where Admins can upload viewable files (html, pdf, txt, ect.) for members to view. All is working fine until I started to code the "Delete File" portion. When I tell it to delete a file I get a "Permission denied" error back. I have tried both local file system address (/home/[cpanelname]/...) and I get the “Permission denied” error. And when I try the URL (http://www...) I get a "File does not exist" error, when in fact it does. Is the unlink command blocked on the servers and if so, is there a work-a-round? Many Thanks, David Quote
TweezerMan Posted June 15, 2006 Posted June 15, 2006 I suspect the "Permission denied" message is not related to using the 'unlink' command, but rather, your script does not have appropriate directory permissions to delete the file. To delete a file, the script, running as the user 'nobody', must have write permissions for the directory that contains the file. If you own the directory (you created it), that directory would need to have 0777 permissions. If 'nobody' owns the directory (a PHP script created it), the directory should have at least 0755 permissions. Quote
Dman8568 Posted June 15, 2006 Author Posted June 15, 2006 ...If you own the directory (you created it), that directory would need to have 0777 permissions. If 'nobody' owns the directory (a PHP script created it), the directory should have at least 0755 permissions. the target directory is inside my media folder. The media folder is then sub-divided by file extentions (htm folder, img folder, etc.) All the sub-division folders were created by me through SmartFTP. Therefor, I would need to set the folder to 0777? But isn't that a security risk? (setting a public folder to 0777) Quote
TweezerMan Posted June 15, 2006 Posted June 15, 2006 Therefore, I would need to set the folder to 0777? But isn't that a security risk? (setting a public folder to 0777) Yes, but it is the only way you'll be able to accomplish what you're wanting to do. To minimize the risk, you'd want to make sure your scripts are secure, that no one can upload just any file into that directory, and make regular backups of your site, as this directory would be vulnerable if any account on your server is compromised. Quote
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.