My function below works, but in Linux, some files and folders are not removed, I believe it is, the server does not allow to be running in browser.
If I run the function in shh or give permission for 777 shh or ftp, files and folders are deleted normally.
But the server blocked permission change for browser.
I guess I need to run my pagina.php the shell, but how to do this in a pagina.php running on the browser?
My function:
<?php
function deleteItem($item) {
if (file_exists($item)) {
if (is_dir($item)) {
$folders = scandir($item);
foreach ($folders as $folder) {
if ($folder != '.' && $folder != '..') {
$file = $item . "/" . $folder;
if (filetype($file) == "dir") {
deleteItem($file);
} else {
unlink($file);
}
}
}
reset($folders);
rmdir($item);
} else {
unlink($item);
}
}
}
?>