Helpful Information
 
 
Category: PHP
deleteing directories

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

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.

<?
unlink('filename.file');
?>

oops, I meant a whole directory, which has loads of other directories, not files.

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

www.php.net/rmdir

Try that

Jee

I guess You probably need to have all files in your directory to be correctly chmodded...

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 !! :)

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

That didn't delete anything :s

Just trie everything on this page

http://www.php.net/manual/en/function.rmdir.php

Nothing worked.

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?

G

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.

G










privacy (GDPR)