加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 在php中上传正在运行的文件

发布时间:2020-12-15 02:12:45 所属栏目:Java 来源:网络整理
导读:我知道这听起来很奇怪.我的服务器上有一个php文件,负责处理上传.我桌面上的 java程序将文件发送到这个php文件.我想随时取消文件上传过程到服务器.所以我想创建一种流或类似的东西来阻止正在进行的上传过程. 我试图使用PID来阻止php文件的运行.但是在客户端完
我知道这听起来很奇怪.我的服务器上有一个php文件,负责处理上传.我桌面上的 java程序将文件发送到这个php文件.我想随时取消文件上传过程到服务器.所以我想创建一种流或类似的东西来阻止正在进行的上传过程.

我试图使用PID来阻止php文件的运行.但是在客户端完成上传之前,php文件没有开始运行.

我想在上传开始之前运行“savePid()”函数.所以我可以随时获取PID并停止运行该文件.

<?php
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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读