我正在构建一个带有上传表单的网站。它最多只能上传 120 Kb,但如果尝试更大的内容,浏览器会超时。没有错误消息,浏览器只是超时。
到目前为止我所做的事情:
更改了所有 php.ini 设置、.htaccess 设置;
尝试过不同的浏览器;
在另一台服务器(托管公司)上重建表单并且工作正常 (删除了上传的所有内容,除了基本的内容);
这就是事情开始变得奇怪的地方。它在我 friend 的计算机上运行良好。
我想我已经消除了:
- 编码 - 因为它确实有效;
- 服务器 - 因为它在他们的计算机和我 friend 的计算机上运行良好
- 浏览器 - 嗯,我使用了另一家网络托管公司,并且该表单与他们配合良好,所以我猜测这不是浏览器问题,甚至不是我的互联网连接问题,甚至可能是我计算机上的设置问题?里>
问题出在我的网站上,该表单不适用于超过 120 kb 的任何内容。在另一台服务器上的测试网站上它确实有效。只有我的电脑不行,别人的电脑可以。为什么设置为 120 kb。我错过了什么吗?我非常看重这件事,就好像互联网、我的电脑或技术不喜欢我一样。
编辑1:
我刚刚尝试了其他方法。我买了另一台电脑并在上面进行了尝试,以排除计算机出现问题的可能性。在我家的另一台计算机上仍然无法工作 - 所以我正在考虑我的宽带提供商?但这并不能解释为什么另一台服务器上的测试网站工作正常?
最佳答案
检查您的设置:
php.ini
; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size=10M
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize=512M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 10
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30
; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; http://php.net/max-input-time
max_input_time = 60
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
It's important after editing php.ini file to restart your httpd server, to re-read php.ini file!
Make sure that you set units correctly. There is no shorthand-bytes like "MB". You should use "K", "M", "G" for that. Check this PHP FAQ.
httpd.conf 或/和 .htaccess
php_value post_max_size 10M
php_value upload_max_filesize 512M
关于php - 上传表单 - 无法上传/发布超过 120 Kb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19844231/