我想从目标文件夹中删除文件夹。 我的目标文件夹是:= pdf-files /
In that pdf-files/folder-1/
Now in folder1/subfolder-1
folder1/subfolder-2
folder1/.pdffile
现在当我在zip文件夹-1下载时,它下载但下载时我也从pdf文件夹中删除/删除整个文件夹-1。
这是我的zip文件代码: -
<?php
$sMainFolder = $_GET['main_folder'];
$sFolder = $_GET['folder_name'];
$the_folder = $sMainFolder.$sFolder;
$zip_file_name = $sFolder.'.zip';
$download_file= true;
//$delete_file_after_download= true;
class FlxZipArchive extends ZipArchive {
/** Add a Dir with Files and Subdirs to the archive;;;;; @param string $location Real Location;;;; @param string $name Name in Archive;;; @author Nicolas Heimann;;;; @access private **/
public function addDir($location, $name) {
$this->addEmptyDir($name);
$this->addDirDo($location, $name);
} // EO addDir;
/** Add Files & Dirs to archive;;;; @param string $location Real Location; @param string $name Name in Archive;;;;;; @author Nicolas Heimann
* @access private **/
private function addDirDo($location, $name) {
$name .= '/';
$location .= '/';
// Read all Files in Dir
$dir = opendir ($location);
while ($file = readdir($dir))
{
if ($file == '.' || $file == '..') continue;
// Rekursiv, If dir: FlxZipArchive::addDir(), else ::File();
$do = (filetype( $location . $file) == 'dir') ? 'addDir' : 'addFile';
$this->$do($location . $file, $name . $file);
}
} // EO addDirDo();
}
$za = new FlxZipArchive;
$res = $za->open($zip_file_name, ZipArchive::CREATE);
if($res === TRUE)
{
$za->addDir($the_folder, basename($the_folder));
$za->close();
}
else { echo 'Could not create a zip archive';}
if ($download_file)
{
ob_get_clean();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=" . basename($zip_file_name) . ";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($zip_file_name));
}
?>
以上脚本下载文件夹但不删除文件夹表格pdf-files文件夹