[英]How to delete zip file with PHP
in my project, I have downloaded 17111611185.zip file with ajax. 在我的项目中,我已经用ajax下载了17111611185.zip文件。
After downloading the zip file, I want to delete this file from my linux server. 下载完zip文件后,我想从Linux服务器上删除该文件。
So after window.location=data, ajax is called again for passing 17111611185.zip to server. 因此,在window.location = data之后,再次调用ajax以将17111611185.zip传递到服务器。
$.ajax({
type:'POST',
data:{files:files},
url:'oat.php',
success:function(data){// data is 17111611185.zip
window.location=data;
//2017-12-19delete zip file
$.ajax({
type:'POST',
data:{delFile:data},
url:'delFileoat.php',
success:function(data){
}
});
}
});
The delFileoat.php code is: delFileoat.php代码为:
<?php
if(isset($_POST['delFile'])){
$delFile=$_POST['delFile'];
unlink($delFile);
}
?>
But unlucky, the return message is 17111611185.zip can not be found. 但很不幸,找不到返回消息17111611185.zip。 And delete progress is fail.
并且删除进度失败。
It seems nothing wrong. 看来没错。 When I just download file without deleteing, like:
当我只下载文件而不删除文件时,例如:
$.ajax({
type:'POST',
data:{files:files},
url:'oat.php',
success:function(data){// data is 17111611185.zip
window.location=data;
}
});
It works OK. 可以。 But fail, when deleting code is added.
但是失败,添加删除代码时。
我认为上传的文件位于tmp文件夹中,可以通过
ini_get('upload_tmp_dir');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.