bassguru Posted September 17, 2009 Share Posted September 17, 2009 Hello everyone I am attempting to delete a folder on my WAMP computer using unlink(). The problem is that I recieve the following error when I run the script: Warning: unlink(...) [function.unlink]: Permission denied in C:\wamp\www\...php Here is the code: if ($file) { $deleteFile = $file; unlink("images/display/".$deleteFile); } I doubt there is a problem with the code. How do I sort the permission for the Apache? When the folders are created they are given a permission of 0777 so it should be OK? Perhaps its just Windows =[ Many thanks in advance bassguru Quote Link to comment https://forums.phpfreaks.com/topic/174640-solved-permission-denied-for-unlink-on-directory/ Share on other sites More sharing options...
MadTechie Posted September 17, 2009 Share Posted September 17, 2009 Setting permissions to 0777 has no effect on a windows platform I would say change the files permissions to everyone, and re-try the script, but if you created the file via a php script it should be fine.. try rebooting windows then try a simple 1 line script to delete the file, if that works. then I would guess you have one of the following problems 1. the file has been opened and not closed. 2. the $file is empty and PHP is attempting to unlink a folder 3. you have some special permission set to stop the deleting process Quote Link to comment https://forums.phpfreaks.com/topic/174640-solved-permission-denied-for-unlink-on-directory/#findComment-920426 Share on other sites More sharing options...
bassguru Posted September 18, 2009 Author Share Posted September 18, 2009 Sorry for wasting everyone's time! I was attempting to delete a folder with unlink() (which is a function for file deletion, not folder deletion). I am now using rmdir(), which works perfectly. The only problem is when there are files inside the folder (rmdir cannot delete directories when there are files stored within them) I am deleting, in which case I have a script that deletes all the files inside the folder before it deletes the actual folder itself. Quote Link to comment https://forums.phpfreaks.com/topic/174640-solved-permission-denied-for-unlink-on-directory/#findComment-920729 Share on other sites More sharing options...
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.