.zip
文件中,我将响应发送回ajax。
我的php
// Multiple download (checkboxes)
if(isset($_POST["checkboxes_down"])) {
// create a tmp folder for the zip file
$tmpfolder = $MainFolderName.'/tmpzip';
if (!is_dir($tmpfolder)) {
mkdir($tmpfolder, 0755, true);
}
$checkboxfiles = explode("," , $_POST["checkboxes_down"]);
$filename = "archive.zip";
$filepath = $tmpfolder."/";
foreach($checkboxfiles as $checkboxfile) {
Zip($checkboxfile, $tmpfolder."/archive.zip");
}
// send the path to file back as response
echo $filepath.$filename;
unlink($tmpfolder.'/archive.zip'); // unlink archive.zip
rmdir($tmpfolder); // remove tmpdir
exit;
}
$.ajax({
url:"",
method:"POST",
data:{ checkboxes_down:checkboxes_down },
success:function(response){
window.location = response; // redirec to .zip file for download
}
我希望响应和重定向比从tmpfolder取消链接更快。但不幸的是,我不能用
unlink
我在php文件中创建它的方式。
所以我怎样才能解开
tmpfolder
响应成功并重定向后?在取消链接之前,我应该用一些东西作为延迟吗?