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
https://forums.phpfreaks.com/topic/131916-php-clear-folder/
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
https://forums.phpfreaks.com/topic/131916-php-clear-folder/#findComment-685327
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.