Jump to content

PHP - Clear Folder


stormx

Recommended Posts

Hello all,

 

I am currently trying to create a script to empty/clear out a folder, so far its failed.

 

This is my current code:

 

<?

rmdir("/home/root/public_html/images/temp/");

?>

 

I give it the permissions 777, it gives me a 500 error. When it's on default 644 permissions, I get the error:

 

 

Warning: rmdir(/home/root/public_html/images/temp/) [function.rmdir]: No such file or directory in /home/root/public_html/images/delete_files.php on line 3

 

Now I believe everything is correct, I just can't figure it out, please help:)

 

Link to comment
Share on other sites

rmdir does just that removeds the directory.

 

If you only want to remove the directory contents then there isn't a built in function for this. You'll have to piece together your own function, such as this.

 

Alternatively just use rmdir to remove the directory completely then mkdir to recreate it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.