この SO スレッドに従って、ディレクトリを再帰的に削除しました (以下のコードを参照)。問題は、ディレクトリの内容を圧縮して zip ファイルをダウンロードした後、これらのコマンドを実行できないことです。
私が言ったように、フォルダーの圧縮が関係していない場合、コードは問題なく機能するため、ファイル/フォルダーのアクセス許可は問題ではないようです。
誰にもアイデアはありますか?
$this->zip->download($file_name); //a Codeigniter function, though think it could be any function that executes the zip file download.
$dir='uploads/folder1';
//the contents of folder1 are "foo1.png" and "foo2.png"
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $fileinfo) {
$todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink');
$todo($fileinfo->getRealPath());
}
rmdir($dir);