On my way to learning the mkdir();
function in PHP, I have created a folder on my server with a path like so
files/New\\\\
Now, I can not delete this for the life of me... I found one other post that said I would need to use
rmdir();
and escape the backslashes with more backslashes...
Needless to say, I can not get this to work... I had no idea that PHP added slashes through a post. I know from here forth I should use stripslashes();
but for now, I am stuck with two non deletable folders.
Any ideas guys?
Quick'n'dirty script:
$filename = glob('../files/*');
foreach($filename as $file) {
print "'". $file. "' ";
if(strstr($file,'New')) {
if(is_file($file)) {
unlink($file);
}
}
}
foreach($filename as $file) {
if(strstr($file,'New')) {
r_rmdir($file);
}
}
function r_rmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") r_rmdir($dir."/".$object); else unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}