我知道这听起来很奇怪.我的服务器上有一个php文件,负责处理上传.我桌面上的java程序将文件发送到这个php文件.我想随时取消文件上传过程到服务器.所以我想创建一种流或类似的东西来阻止正在进行的上传过程.
我试图使用PID来阻止php文件的运行.但是在客户端完成上传之前,php文件没有开始运行.
我想在上传开始之前运行“savePid()”函数.所以我可以随时获取PID并停止运行该文件.
include('func.php');
savePid(); //run this before upload started
$in = stream_get_contents(fopen("php://input", "rb"));
$out = fopen('pipeupload.txt', 'w');
while ( ! feof($in) ) {
fwrite($out, fread($in, 8192));
}
?>
我知道这不行.我只是在寻找一种解决方案来阻止正在进行的上传过程.
解决方法:
它可能在服务器端.
示例:
You have 20 images, every image is more than 2 mb in size. Your java
file from desktop send array of url’s of images which is ready to
upload by php file as you told. In the php file you have to do some
change, before every image upload you have to check in database
(create table and add new field image_cancel or add this field in your
prev table, set default value is false) column name image_cancel is
true/false. if it true then stop execution and exit. Now create a new
script cancel_image.php —> Write code inside and set image_cancel
field true.
标签:php,java,upload
来源: https://codeday.me/bug/20190711/1432130.html