我發誓這是昨天的工作.然而,現在下面的代碼破壞文件夾沒有問題,但創建一個具有411權限的新文件夾應該是777.我的代碼昨天這樣做.
這樣做的目的是壓縮文件夾,傳遞文件夾,刪除圖像,然后為圖像創建新目錄.
有人能告訴我我做錯了什么或我應該做什么?謝謝
function delete_directory($dirname) {
if (is_dir($dirname))
$dir_handle = opendir($dirname);
if (!$dir_handle)
return false;
while($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
if (!is_dir($dirname."/".$file))
unlink($dirname."/".$file);
else
delete_directory($dirname.'/'.$file);
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
$directoryToZip="jigsaw/"; // This will zip all the file(s) in this present working directory
$outputDir="/"; //Replace "/" with the name of the desired output directory.
$zipName="jigsaw.zip";
include_once("createzipfile/CreateZipFile.inc.php");
$createZipFile=new CreateZipFile;
/*
// Code to Zip a single file
$createZipFile->addDirectory($outputDir);
$fileContents=file_get_contents($fileToZip);
$createZipFile->addFile($fileContents, $outputDir.$fileToZip);
*/
//Code toZip a directory and all its files/subdirectories
$createZipFile->zipDirectory($directoryToZip,$outputDir);
/*
$rand=md5(microtime().rand(0,999999));
$zipName=$rand."_".$zipName;
*/
$fd=fopen($zipName, "wb");
$out=fwrite($fd,$createZipFile->getZippedfile());
fclose($fd);
$createZipFile->forceDownload($zipName);
@unlink($zipName);
delete_directory('jigsaw/assets/images/jigsaw_image');
mkdir('jigsaw/assets/images/jigsaw_image','0777');