PHP - Maximum Total Upload Size?

2019-01-18 00:24发布

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 launch, I will be moving this web page to another Linux shared hosting environment (still not sure which). Are there some web hosting environments that limit the size of total uploads in one http request?

标签: php upload limit
9条回答
狗以群分
2楼-- · 2019-01-18 00:57

here:

max_execution_time
max_input_time
memory_limit
post_max_size
upload_max_filesize
max_file_uploads 
查看更多
男人必须洒脱
3楼-- · 2019-01-18 00:57

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);      
}
查看更多
虎瘦雄心在
4楼-- · 2019-01-18 01:02

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.

查看更多
登录 后发表回答