取消HTTP POST请求服务器端 [英] Cancel an HTTP POST request server side

查看:490
本文介绍了取消HTTP POST请求服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写用于上传大文件(> 500MB)的脚本。我想在处理上传之前进行一些身份验证,例如:

I am trying to write a script for uploading large files (>500MB). I would like to do some authentication before the upload is processed, eg:

$id = $_GET['key'];
$size = $_GET['size'];
$time = $_GET['time'];
$signature = $_GET['signature'];

$secret = 'asdfgh123456';

if(sha1($id.$size.$time.$secret) != $signature){
echo 'invalid signature';
exit;
}
process upload...

不幸的是php只运行此代码该文件已上载到临时目录,占用宝贵的服务器资源。在上传发生之前有没有办法做到这一点?我用perl / cgi尝试了类似的事情,但同样的事情发生了。

unfortunately php only runs this code after the file has been uploaded to a temp directory, taking up valuable server resources. Is there a way to do this before the upload happens? I have tried similar things with perl/cgi but the same thing happens.

推荐答案

哇,已经有5个答案告诉它怎么可能'完成。 mod_perl to救援,您可以在上传整个请求正文之前拒绝请求。

Wow, already 5 answers telling how it can't be done. mod_perl to the rescue, here you can reject a request before the whole request body is uploaded.

这篇关于取消HTTP POST请求服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆