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);
}
}
1.
This should remove all the folders and files you have created for both directories, just run this script and it should remove them both completely
PHP
rmdir("../files/New\\\\/thumbnail");
rmdir("../files/New\\\\");
$filename = glob('../files/New\\\\\\\\\\\\\\\\/*');
foreach($filename as $file) {
if(is_file($file)) {
unlink($file);
}
}
rmdir("../files/New\\\\\\\\\\\\\\\\/thumbnail");
rmdir("../files/New\\\\\\\\\\\\\\\\");
2.
Have you tried renaming the folder with php? Like, so
PHP
$oldname = '../files/New\\\\';
$newname = '../files/please';
rename($oldname, $newname);