6

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?

Luc M
  • 16,630
  • 26
  • 74
  • 89
John
  • 32,403
  • 80
  • 251
  • 422

9 Answers9

21

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.

Rob
  • 47,999
  • 5
  • 74
  • 91
6

The upload limits are set through php ini. You can try get them like so:

$post_max_size = ini_get('post_max_size');
$upload_max_filesize = ini_get('upload_max_filesize');
andi
  • 14,322
  • 9
  • 47
  • 46
4

It's a setting in php.ini. You can look in the output of php info for the field labeled "upload_max_filesize". To get a php info page, create a php file with the following code:

<?php phpinfo(); ?>

This post at php.net gives you sample code to get that information, and the rest of the page is a treasure trove of php configuration options.

Benson
  • 22,457
  • 2
  • 40
  • 49
4

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.

Seb
  • 24,920
  • 5
  • 67
  • 85
  • `file_uploads`, `memory_limit` and `max_execution_time` do not limit the maximum total upload size. – Gumbo Apr 07 '09 at 22:03
0

If you are using nginx then make sure that you have the following:

server {
...
     client_max_body_size 100M;
....
}
Graymatter
  • 6,529
  • 2
  • 30
  • 50
0

here:

max_execution_time
max_input_time
memory_limit
post_max_size
upload_max_filesize
max_file_uploads 
EKanadily
  • 3,831
  • 3
  • 35
  • 33
0

This would be unusual, but of course, check with whatever hosting company you choose. If there were a limit, it certainly would be higher than 30 MB.

John Rasch
  • 62,489
  • 19
  • 106
  • 139
0

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.

Tjofras
  • 2,116
  • 12
  • 13
-1

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);      
}
Attila Fulop
  • 6,861
  • 2
  • 44
  • 50