Access Denied To Php's Unlink Command

liunx

Guest
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.<br /><br />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 鎻歟rmission denied?error. And when I try the URL (<!-- m --><a class="postlink" href="http://www..">http://www..</a><!-- m -->.) I get a "File does not exist" error, when in fact it does.<br /><br />Is the unlink command blocked on the servers and if so, is there a work-a-round?<br /><br /><br /><br />Many Thanks,<br />David<!--content-->
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.<br /><br />To delete a file, the script, running as the user 'nobody', must have write permissions for the directory that contains the file.<br /><br />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.<!--content-->
<!--quoteo(post=182662:date=Jun 14 2006, 10:40 PM:name=TCH-David)--><div class='quotetop'>QUOTE(TCH-David @ Jun 14 2006, 10:40 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182662"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->...<br />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.<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br />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. <br /><br />Therefor, I would need to set the folder to 0777? But isn't that a security risk? (setting a public folder to 0777)<!--content-->
<!--quoteo(post=182663:date=Jun 14 2006, 07:58 PM:name=Dman8568)--><div class='quotetop'>QUOTE(Dman8568 @ Jun 14 2006, 07:58 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182663"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Therefore, I would need to set the folder to 0777? But isn't that a security risk? (setting a public folder to 0777)<!--QuoteEnd--></div><!--QuoteEEnd--><br />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.<!--content-->
 
Top