【发布时间】:2014-07-22 12:32:29
【问题描述】:
这个问题被问了数百万次,但我三天以来一直在与这个问题作斗争,我完全糊涂了。
我无法强制 PHP 在 $_SESSION (http://www.php.net/manual/en/session.upload-progress.php) 中保存有关上传文件的详细信息。我只能得到空会话。
我的代码最简单的例子:
index.php
<?php
session_start();
$_SESSION['test'] = 'TEST';
?>
<form action="index.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
print_r($_SESSION);
?>
结果 - 点击提交后 ;)
Array ( [test] => TEST ) // nothing more...
php -i | grep upload_progress
session.upload_progress.cleanup => Off => Off
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
php -i | grep 大小
post_max_size => 2G => 2G
realpath_cache_size => 16K => 16K
upload_max_filesize => 2G => 2G
Command buffer size => 4096
Read buffer size => 32768
- 上传文件的文件大小(本地主机):2 x 1.5GB
- 执行时间:8 秒
- 我正在使用 Gentoo linux 和 php 5.5.12,Apache 2 编译 没有快速 CGI 支持。
参考书目:
https://stackoverflow.com/a/21851657/1125465 - 就我而言,这些在我的配置中都可以。
https://stackoverflow.com/a/13186859/1125465 - 尝试了所有脚本和所有版本。 SESSION superglobal 对于每个都是空的。
https://stackoverflow.com/a/11485170/1125465 - 正如我评论这个答案...不是答案。
请帮忙!我开始失去理智了。最好的问候。
UPDATE phpinfo() 结果截图:
值得注意的是,文件正在上传到 tmp 目录,没有任何麻烦。
【问题讨论】:
-
你使用的是什么版本的 PHP?
-
PHP 5.5.12,Apache 2 编译时不支持快速 CGI。 (删除评论:PHP 应该自动初始化 $_SESSION["upload_progress_123"]。请参阅我的问题中的链接:php.net/manual/en/session.upload-progress.php)。谢谢你的兴趣:)。
标签: php session upload progress