問題描述
用戶在我的網站上上傳圖片時遇到很多問題.
I have been having lot of problems with users uploading images on my website.
他們最多可以上傳 6 張圖片
They can upload up to 6 images
最初我不得不將 php.ini 中的值更改為:
Originally I had to change values in php.ini to:
upload_max_filesize = 2000M
post_max_size = 2000M
max_execution_time = 120
max_file_uploads = 7
memory_limit=128M
我不得不改成這樣,因為出現各種錯誤,例如內存不足、超過最大帖子數等.
I had to change to this as was getting all sorts of errors like out of memory, maximum post exceeded etc.
一切正常,直到我檢查了包含以下內容的錯誤日志:
Everything was going ok till I checked my error log which contained :
[11-Jun-2011 04:33:06] PHP Warning: Unknown: POST Content-Length of 113 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:33:12] PHP Warning: Unknown: POST Content-Length of 75 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:33:27] PHP Warning: Unknown: POST Content-Length of 74 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:33:34] PHP Warning: Unknown: POST Content-Length of 75 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:33:43] PHP Warning: Unknown: POST Content-Length of 77 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:33:48] PHP Warning: Unknown: POST Content-Length of 74 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:33:53] PHP Warning: Unknown: POST Content-Length of 75 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:34:20] PHP Warning: Unknown: POST Content-Length of 133 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:35:29] PHP Warning: Unknown: POST Content-Length of 131 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:36:00] PHP Warning: Unknown: POST Content-Length of 113 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:36:06] PHP Warning: Unknown: POST Content-Length of 75 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
[11-Jun-2011 04:36:34] PHP Warning: Unknown: POST Content-Length of 116 bytes exceeds the limit of -1988100096 bytes in Unknown on line 0
如果我將帖子最大值更改回 8M,我會收到如下消息:
if I change the post max value back top 8M I get message like this:
PHP Warning: POST Content-Length of 11933650 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
有什么想法我哪里出錯了嗎?
Any ideas where I am going wrong?
推薦答案
在某些 32 位系統上,PHP 將采用 2000M
或 2G
等內存設置并將其轉換為不執行邊界檢查的整數字節.以 2G
或 2048M
開頭的數字將是 -2147483648
個字節.
On some 32bit systems PHP will take the memory settings like 2000M
or 2G
and convert it to the integer number of bytes by not performing a boundary check. A number starting at 2G
or 2048M
will be -2147483648
bytes then.
某些 PHP 版本將其限制在頂部,因此它不會變成負數(即 32 位有符號整數限制).
Some PHP versions cap this at the top, so it won't go into negative numbers (that is the 32 bit signed integer limit).
如果您想在這樣的系統上獲得最大可能的字節數,請使用 2147483647
.這等于 2 GB 減 1 個字節.
If you want to achieve the maximum possible number of bytes on such a system then, use 2147483647
. This is equal to two gigabytes minus one byte.
或者,如果您需要處理大數據,請考慮使用 64 位系統.
Alternatively if you need to deal with large data, consider a 64bit system.
此外,您還應該考慮以下事項:
Additionally you should consider the following:
根據 PHP 手冊,memory_limit
設置是更重要的一項.如果它沒有提供足夠的內存,則后期數據大小檢查將通過,但 PHP 將沒有足夠的內存來實際處理后期數據.您將收到另一個錯誤,即內存超出.因此,在配置 PHP 時,請注意 post_max_size
小于 memory_limit
.
According to the PHP manual, the memory_limit
setting is the more important one. If it does not offer enough memory, the post-data size-check then will pass, but PHP would not have enough memory to actually handle the post-data. You will get another error than, that the memory exceeded. So when you configure your PHP, take care that post_max_size
is smaller than memory_limit
.
在您的示例中,memory_limit
是 128M
,因此它無法處理大小大于 ~128 兆字節的后期數據.
In your example the memory_limit
is 128M
, so it can not process post-data of a size larger than ~128 Megabyte.
(這篇博文顯示會發生什么以及 32 位和 64 位系統上的大內存設置的行為有多大)
這篇關于PHP 警告:113 字節的 POST Content-Length 超出了 Unknown 中 -1988100096 字節的限制的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!