php ajax 回调路径,接收到ajax回调后如何在php中取消文件链接

.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

响应成功并重定向后?在取消链接之前,我应该用一些东西作为延迟吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值