Welcome Guest, Not a member yet? Register   Sign In
Delete files from directory
#13

[eluser]Unknown[/eluser]
This is code of delete_files function :

function delete_files($path, $del_dir = FALSE, $level = 0)
{
// Trim the trailing slash
$path = preg_replace("|^(.+?)/*$|", "\\1", $path);

if ( ! $current_dir = @opendir($path))
return;

while(FALSE !== ($filename = @readdir($current_dir)))
{
if ($filename != "." and $filename != "..")
{
if (is_dir($path.'/'.$filename))
{
// Ignore empty folders
if (substr($filename, 0, 1) != '.')
{
delete_files($path.'/'.$filename, $del_dir, $level + 1);
}
}
else
{
unlink($path.'/'.$filename);
}
}
}
@closedir($current_dir);

if ($del_dir == TRUE AND $level > 0)
{
@rmdir($path);
}
}
You can see at http://ellislab.com/codeigniter/user-gui...elper.html show that :

delete_files('path')

Deletes ALL files contained in the supplied path. Example:
delete_files('./path/to/directory/');

It mean : you supply argument is path not file !

My English is not good :d


Messages In This Thread
Delete files from directory - by El Forum - 06-27-2008, 12:44 AM
Delete files from directory - by El Forum - 06-27-2008, 06:51 AM
Delete files from directory - by El Forum - 06-27-2008, 09:41 AM
Delete files from directory - by El Forum - 06-27-2008, 10:00 AM
Delete files from directory - by El Forum - 06-29-2008, 10:35 PM
Delete files from directory - by El Forum - 07-16-2008, 11:12 PM
Delete files from directory - by El Forum - 09-10-2009, 06:36 PM
Delete files from directory - by El Forum - 09-10-2009, 06:52 PM
Delete files from directory - by El Forum - 09-10-2009, 07:17 PM
Delete files from directory - by El Forum - 11-24-2009, 05:30 PM
Delete files from directory - by El Forum - 11-24-2009, 09:40 PM
Delete files from directory - by El Forum - 12-21-2009, 11:16 PM
Delete files from directory - by El Forum - 02-01-2010, 10:20 PM
Delete files from directory - by El Forum - 03-14-2010, 08:12 AM
Delete files from directory - by El Forum - 12-30-2010, 06:29 PM
Delete files from directory - by El Forum - 01-01-2011, 02:14 AM
Delete files from directory - by El Forum - 04-06-2012, 07:33 PM
Delete files from directory - by El Forum - 04-06-2012, 07:42 PM
Delete files from directory - by El Forum - 05-24-2012, 04:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB