vulkan vulkan - 3 months ago 33
PHP Question

unlink() with scandir() . php error Permission denied (document/.) and (document/..)

In the folder "

scanner ()
" whether screening, after "
unlink ()
" and I do unenroll ,If deleting the files in the folder, but I am getting permission denied error :

Warning: unlink(path/.): Permission denied in unlink.php on line

Warning: unlink(path/..): Permission denied in unlink.php on line


my
unlink
php code :

$Pscan = scandir("img/movieData/$m_folder/poster/");
foreach($Pscan as $Pscan_name){
unlink("img/movieData/$m_folder/poster/$Pscan_name");
}

Answer

problem fixed :

$Pscan = scandir("img/movieData/$m_folder/poster/");
         foreach($Pscan as $Pscan_name){
             // fixed
             if($Pscan_name == '.' || $Pscan_name == '..'){
                   continue;
             }else{
                   unlink("img/movieData/$m_folder/poster/$Pscan_name");
             }   
         }
Comments