gpt4 book ai didi

java - 在php中上传一个正在运行的文件

转载 作者:可可西里 更新时间:2023-10-31 23:46:18 25 4
gpt4 key购买 nike

我知道这听起来很奇怪。我的服务器上有一个 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.

关于java - 在php中上传一个正在运行的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35078726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com