0

I can't remove installition joomla folder from hosting

My code is:

    $settings['install_folder_name'] = __DIR__.'/installation';

    if(file_exists($settings['install_folder_name'])) {
    
        chmod($settings['install_folder_name'], 0777);
        rmdir($settings['install_folder_name']);
    }

But it doesn't work, why?

dream fly
  • 1
  • 1

1 Answers1

-1

You need to recursively remove folder/files inside of folder. Because, when folder contains any items (subfolders or files) you can not remove folder. For example, in PHP you can write custom function:

function rrmdir($dir) { 
   if (is_dir($dir)) { 
     $objects = scandir($dir);
     foreach ($objects as $object) { 
       if ($object != "." && $object != "..") { 
         if (is_dir($dir. DIRECTORY_SEPARATOR .$object) && !is_link($dir."/".$object))
           rrmdir($dir. DIRECTORY_SEPARATOR .$object);
         else
           unlink($dir. DIRECTORY_SEPARATOR .$object); 
       } 
     }
     rmdir($dir); 
   } 
 }


Addionally, visit here: How do I recursively delete a directory and its entire contents (files + sub dirs) in PHP?

Tural Rzaxanov
  • 783
  • 1
  • 7
  • 16