Jump to content

Empty but not delete a directory


bobinindia

Recommended Posts

i have tried your code like this and the folder has the correct permissions. Any other suggestions?

<?php
function empty_dir ($dir)
{
$files = glob("*");
foreach($files as $file)
{
	if(is_dir($file))
	{
		if($file != "." && $file != "..")
			empty_dir($dir.$file."/");
	}
	else
		unlink($file);
}
}
$dir = "images/changer/";
empty_dir($dir);
?>

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.