php - PHP 清空 $_POST 和 $_FILES 并上传大文件
问题描述
请不要将此作为重复项关闭。我知道这里发布了许多类似的问题,但我已经尝试了所有这些答案,但问题没有改变。我已经研究了一个多星期。我找到的所有答案都在谈论我已经正确设置的以下设置。
我的 MAMP 服务器的 php.ini 包括以下内容:
file_uploads On
upload_max_filesize 16700000
post_max_size 16777216
memory_limit 768M
max_input_time 360
max_execution_time 360
我的 .htaccess 文件重复这些:
php_value file_uploads On
php_value upload_max_filesize 16700000
php_value post_max_size 16777216
php_value memory_limit 768M
php_value max_input_time 360
php_value max_execution_time 360
并且还有:
LimitRequestBody 16777216
<IfModule mod_security2.c>
SecRequestBodyLimit 16777216
SecRequestBodyNoFilesLimit 16777216
</IfModule>
我的 httd.conf 文件包含相同的设置。
当我在运行时使用 进行检查时ini_get()
,我看到了上面给出的 php ini 值,但max_execution_time
无论这些设置如何,它始终为 0(无限制)。
使用FormData
in a XMLHttpRequest
,如果我上传的文件最大约为 1meg,则 Content-length 标头看起来正确并且一切正常。如果我上传一个稍微大一点的文件,我会看到所有相同的值, Content-length 标头看起来正确(并且小于post_max_size
),但是$_POST
和$_FILES
是空的,并且客户端会看到 HTTP status 413 Request Entity Too Large
。php 和 apache 日志文件均未显示错误。
更新:
在进一步调查中,我发现Requested content-length of 1829686 is larger than the configured limit of 1024000
. apache_ssl_request.log
那么这个 1024000 的限制是从哪里来的呢?这是什么境界?find /Applications/MAMP -type f -exec grep -l 1024000 '{}' \;
仅找到此错误消息,没有具有此值的配置文件条目。
解决方案
推荐阅读
- jquery - 具有多个名称的字段上的多个选择器 []
- git - Git 中的服务器外合并
- java - 响应式 WebFlux 向特定订阅者发布通知
- python - sqlalchemy ROW_NUMBER() OVER (PARTITION BY) 可选
- sql - POSTGRES 中 Oracle V_$OSSTAT 的等效表或视图
- sql - 如何使用 Microsoft Access 插入多行?
- database - 使用 fmt.Sprintf 防止 Go 中的 sql 注入进行本机查询
- python - 从选定的单元格移动时,Qtablewidget 未记录的崩溃
- embedded-linux - 是否可以在使用 Beaglebone Yocto 启动时使用 systemd 运行多个启动脚本
- reactjs - 单击 SVG 图标重定向到另一个页面