PHP Upload - 500 Internal Server Error

后端 未结 4 2013
难免孤独
难免孤独 2021-01-12 05:49

The Issue

When uploading files of around 8MB or over, I recieve a 500 Internal Server Error.

  1. All PHP settings in php.ini are correct
4条回答
  •  别那么骄傲
    2021-01-12 06:55

    This is a fairly common error and is due to the fact that the size of data being uploaded does not match file size: even if you POST max size is not exceeded by the file size, it could be by the uploaded data size.

    See this page in the PHP manual.

    ; Maximum size of POST data that PHP will accept.
    post_max_size = 8M
    

    Another source of troubles (for VERY large texts) is UTF8 encoding. You might find yourself with a "six megabytes" TEXTAREA that is actually 6 mega*characters*, and with international codepoints it might run to, say, 8.2 megabytes. Thus you get an apparently contradictory situation of "six megabytes data exceed the configured 8 megabytes limit".

    Update

    You report two apparently contradictory facts:

    PHP settings as follows (from phpinfo()):
    
        post_max_size = 64M
    

    and

    PHP Warning: POST Content-Length of 12221448 bytes exceeds the limit of 8388608 bytes
    

    It is clear from the PHPINFO that the limit for POST is 64M. Yet the error says that the limit is 8M (the default). So it seems to me that your code is talking to two different PHP implementations (Two different virtual hosts? A CGI version and a non-CGI version in the same host? Two different machines?)

提交回复
热议问题