View Full Version : deleteing directories

07-03-2002, 01:48 AM
How can I delete files that were made by the server in ftp? Everytime I try I get "Permission denied". Do I have to delete them by a script or something? I've tried everything I can think of. Changing permissions, changing chmod, etc

07-03-2002, 02:11 AM
yes you will need to use a script to delete the files , or change the ownership of the files, & since some hosts wont let you CHOWN then deletion is probably easiest.


07-03-2002, 02:16 AM
oops, I meant a whole directory, which has loads of other directories, not files.

07-03-2002, 03:39 AM
I've tried renaming and unlinking, both come up with permission denied.

Warning: Rename failed (Permission denied) in /home/chatterspics/public_html/clear.php on line 3

The directories are chmoded to 777, if that helps

07-03-2002, 09:50 AM

Try that


07-03-2002, 09:53 AM
I guess You probably need to have all files in your directory to be correctly chmodded...

07-03-2002, 10:42 AM
hmmm OK - you can try this BUT BE VERY CAREFUL!!!!!

exec('rm -f -R thisdirectory');

and I mean careful cos if you get this wrong you get it wrong bigtime! that should remove the directory and all its contents including subdirectories.

again BE CAREFUL !! :)

07-03-2002, 03:08 PM
Ok, I execute that in the directory I want to delete, or name "thisdirectory" to the directory I want to delete? I don't wanna mess it up :s

07-03-2002, 10:18 PM
That didn't delete anything :s

07-03-2002, 10:50 PM
Just trie everything on this page


Nothing worked.

10-25-2002, 01:11 AM
My host told me that this has to do with the PHP script not "running as user". They say that you want to use a perl script to perform these kinds of operations (especially if you dont want the directory to have universal write access). Does this make sense? Is it possible to call a perl script from a php script in order to perform some of these sensitive operations, or is that a mistake?


11-24-2002, 08:59 PM
I finally got this to work. Again, on my host, php does not run with the authority needed to do deletes, renames, etc. So in my php script, I set up a call to a cgi written in perl that handles those actions. It works.