Once I wrote a PHP script which should have downloaded a some images to a normal webserver. Something went wrong with this script and now I have a lot of files in one directory with the filesize 0. When i try to delete one with filezilla the server just responses:
550 nameOfTheFile.jpg: No file or directory
what can I do the get rid of all this datatrash?
It seems like there are only the filenames saved on the server, but not the files
Here's a piece of code I found here
<?php
$dir_stack = array('test/'); // put the directory to delete here **NOTE** everything in this will be deleted.
$i = 0;
while ($i <= count($dir_stack)-1)
{
echo $dir_stack[$i].'<br>';
if ($dir = opendir($dir_stack[$i]))
{
while (false !== ($file = readdir($dir)))
{
if ($file != "." && $file != ".." && false == is_dir($dir_stack[$i].$file))
{
unlink($dir_stack[$i].$file);
}
elseif ($file != "." && $file != "..")
{
array_push($dir_stack,$dir_stack[$i].$file.'/');
}
}
closedir($dir);
}
$i++;
}
$i = count($dir_stack)-1;
while ($i >= 0)
{
rmdir($dir_stack[$i]);
$i--;
}
?>