我正在尝试创建一个 zip 文件夹,但我无法授予 777 权限。请帮我解决这个问题。
这是我的源代码:
$files = ['13150925581920IMG_0009.PNG','1328684363792113286843637921IMG_0009.PNG'];
$random = rand(1111111111,9999999999);
$zipname = 'photos_'.$random.'.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
chmod($zipname, 777);
foreach ($files as $file) {
if(file_exists($file)){
$zip->addFromString(basename($file), file_get_contents($file));
}
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$zipname");
header("Content-length: " . filesize($zipname));
header("Pragma: no-cache");
header("Expires: 0");
readfile("$zipname");