【问题标题】:Does PHP's upload progress feature actually works?PHP的上传进度功能真的有效吗?
【发布时间】:2013-04-30 11:54:49
【问题描述】:

问题是 php 5.4 的上传进度功能似乎不起作用。无论我做什么,都不会填充会话变量。

  • 会填充和设置 session.upload-progress 变量。
  • 文件上传已启用
  • upload_max_filesize 设置为 2000M
  • post_max_size 设置为 2000M
  • upload_tmp_dir 可写
  • 表单中的隐藏变量被设置,它在任何输入元素之前,它的名字是:ini_get("session.upload_progress.name")

到目前为止,在使用 dotdeb php 5.4.14 的 Debian 挤压和使用 php5 模块的 apache2 下没有成功。

我还检查了 apc rfc1867 挂钩。就是行不通。与上传进度扩展相同。有什么想法吗?

使用的例子

对于上传进度: http://www.ultramegatech.com/2010/10/create-an-upload-progress-bar-with-php-and-jquery/

对于 apc: http://blog.famillecollet.com/post/2011/01/12/File-upload-progress-in-PHP-with-APC

对于 php 5.4: https://github.com/chemicaloliver/PHP-5.4-Upload-Progress-Example

php 5.4 inline(上传开始后,只需从另一个选项卡调用相同的文件...):

上传.php:

<?
session_start();
var_dump($_SESSION[ ini_get("session.upload_progress.name") . "123"]);

?>

<form action="upload.php" method="POST" enctype="multipart/form-data">
 <input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="123" />
 <input type="file" name="file1" />
 <input type="file" name="file2" />
 <input type="submit" />
</form>

【问题讨论】:

  • 你的代码是什么样的?

标签: php file-upload nginx


【解决方案1】:

见鬼,nginx 是罪魁祸首。如果它用作代理,它首先存储整个上传,当整个文件到达时,将其发送到 Apache 或您使用的任何其他服务器。因此没有上传进度。

【讨论】:

  • 你应该检查 Nginx 配置我可以想象有一些配置可以控制这种行为。
【解决方案2】:

nginx 1.7.11 现在有一个关闭上传缓冲的选项:

功能:“proxy_request_buffering”、“fastcgi_request_buffering”、 “scgi_request_buffering”和“uwsgi_request_buffering”指令。

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_request_buffering

并使用此选项上传进度,同时现在使用它!

【讨论】:

    猜你喜欢
    • 2012-11-24
    • 2019-09-16
    • 2011-04-12
    • 2013-08-17
    • 2021-08-27
    • 2012-08-04
    • 2016-08-23
    • 1970-01-01
    • 2011-04-30
    相关资源
    最近更新 更多