PHP - Maximum Total Upload Size?

后端 未结 10 1433
说谎
说谎 2020-12-09 13:58

I have a php web page with 15 fields. The user will use it to upload images. I tested this by uploading 15 jpg images, each about 2 M, without any problems. On the day I

相关标签:
10条回答
  • 2020-12-09 14:06

    here:

    max_execution_time
    max_input_time
    memory_limit
    post_max_size
    upload_max_filesize
    max_file_uploads 
    
    0 讨论(0)
  • 2020-12-09 14:07

    There are bunch of PHP settings limiting the upload process:

    • file_uploads
    • upload_max_filesize
    • max_input_time
    • memory_limit
    • max_execution_time
    • post_max_size

    I'd suggest reading this page: http://www.radinks.com/upload/config.php

    While it's true many of these don't limit upload size, they do put a cap on the upload process - e.g. if memory limit is too low, then you'll have problems uploading big files that need to stay in memory for a little period of time.

    0 讨论(0)
  • 2020-12-09 14:07

    I've seen the best solution here so far, and this is the code:

    /**
     * Returns the maximally uploadable file size in megabytes
     *
     * @return  string
     */
    function getMaxUploadSize()
    {
       $max_upload    = (int)(ini_get('upload_max_filesize'));
       $max_post      = (int)(ini_get('post_max_size'));
       $memory_limit  = (int)(ini_get('memory_limit'));
       return min($max_upload, $max_post, $memory_limit);      
    }
    
    0 讨论(0)
  • 2020-12-09 14:09

    the php.ini directive "post_max_size" should limit how much data you can send in a single POST. if you post 15 images in one post I'm pretty sure that is still considered one POST. So it might be good to check this value before going live.

    0 讨论(0)
  • 2020-12-09 14:13

    You can check in php.ini (php setting) in your localhost or hosting.

    in cofiguration setting :

    • max_input_time
    • max_execution_time
    • memory_limit
    • post_max_size
    • max_file_uploads
    • upload_max_filesize
    0 讨论(0)
  • 2020-12-09 14:16

    Yes. There are (as far as I can remember) three or so configuration settings which will affect upload size restrictions:

    • upload_max_filesize, which sets an upper limit on the size of uploaded files
    • post_max_size, which limits the total size of posted data, including file data
    • max_input_time, which restricts the length of time the script is allowed to process input data, including posted values

    upload_max_filesize is a limit on each individual file; however, post_max_size is an upper limit on the entire request, which includes all the uploaded files.

    Different hosting environments will have these values set differently, which may affect your abilities upon deployment.

    0 讨论(0)
提交回复
热议问题