0
這是後續問題在我的question後。在壓縮並刪除一些文件後刪除文件夾內的文件夾
Folder
subfolders
imagefolder
important.txt
index.txt
我有一個子文件夾,如何壓縮的Folder
,然後刪除包括Folder
內的所有文件夾免除important.txt
所有文件?
從previous post。我有這樣的:
$zipFile = "./testZip.zip";
$zipArchive = new ZipArchive();
if (!$zipArchive->open($zipFile, ZIPARCHIVE::OVERWRITE))
die("Failed to create archive\n");
$zipArchive->addGlob("./*.txt");
if (!$zipArchive->status == ZIPARCHIVE::ER_OK)
echo "Failed to write files to zip\n";
$zipArchive->close();
但它給了我這樣的輸出:已創建 testZip.zip
但只包括文件:important.txt
則子文件夾不會被刪除。
你試過我的方法嗎?你還必須添加一個shell('rm -r Folder/subfolders');刪除子文件夾。它是一個非常天真的方法,但也非常強大,只要你不改變文件夾的內容。 – 2011-02-06 18:48:15