No error when uploading a really big file in PHP?

后端 未结 6 805
说谎
说谎 2021-02-06 18:14

I have a PHP form for uploading files and it works fine and displays an error message if something went wrong. This is all good.

The problem is when I test with a really

6条回答
  •  佛祖请我去吃肉
    2021-02-06 18:46

    Check your PHP ini file, which governs how large a file PHP will allow to be uploaded. These variables are important:

    • max upload filesize (upload_max_filesize)
    • max post data size (post_max_size)
    • memory limit (memory_limit)

    Any uploads outside these bounds will be ignored or errored-out, depending on your settings.

    This section in the docs has the best summary: http://ca3.php.net/manual/en/features.file-upload.common-pitfalls.php

    EDIT: Also note that most browsers won't send uploads over 2GB in size. This link is outdated, but gives an idea: http://www.motobit.com/help/scptutl/pa98.htm. Anyone have a better source of info on this?

    There are also limits that can be imposed by the server, such as Apache: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody

    To truly see what's going on, you should probably check your webserver logs, check the browser upload limit (if you're using firefox), and try seeing if print_r($_FILES) generates any useful error numbers. If all else fails, try the net traffic monitor in firebug. The key is to determine if the request is even going to the server, and if it is what the request (including headers) looks like. Once you've gotten that far in the chain, then you can go back and see how PHP is handling the upload.

提交回复
热议问题