我已经成功使用uploadify,我会推荐它。这是一个处理大型上传的 jQuery/Flash 脚本,您可以向它传递额外的参数(如密钥)。要解决服务器端问题,只需使用以下代码。更改仅对调用它们的脚本生效:
//Check to see if the key is there
if(!isset($_POST['secret_key']) || !isValid($_POST['secret_key']))
{
exit("Invalid request");
}
function isValid($key)
{
//Put your validation code here.
}
//This line changes the timeout.
//Give it a value in seconds (3600 = 1 hour)
set_time_limit(3600);
//Set these amounts to whatever you need.
ini_set("post_max_size","8192M");
ini_set("upload_max_filesize","8192M");
//Generally speaking, the memory_limit should be higher
//than your post size. So make sure that's right too.
ini_set("memory_limit","8200M");
编辑回应您的评论:
鉴于您所说,恐怕您可能无法通过http满足您的要求。现有的所有解决方案都包含向 http 添加功能的代码,而这些功能从未为它设计过。
就像你自己说的,这是一个简单的协议。除了编写您自己的在浏览器之外运行的客户端软件、Java 小程序或使用不同的协议(如为此设计的 FTP)之外,您可能无法得到您想要的。
在给定的限制范围内,我已尽我所能。对不起,我不能做得更好。