• Welcome to PHPVIBE Forums. Please log in.
avatar_Marius P.

Server settings for large file uploads

Started by Marius P.,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Marius P.Topic starter

There are multiple server settings that affect file uploads.

On some setups a larger upload may just fail, on others, it may return an error like "Bad response".

Always a good idea to check your server's error_log first, it will give you a clue as to what is the issue.

In most cases increasing these settings on your server is enough:

upload_max_filesize
max_input_time
memory_limit
max_execution_time
post_max_size

Usually, all these configuration settings for your hosting account installation are contained in the php.ini file.


upload_max_filesize and post_max_size

Files are usually POSTed to the webserver in a format known as 'multipart/form-data'. The post_max_size sets the upper limit on the amount of data that a script can accept in this manner. Ideally, this value should be larger than the value that you set for upload_max_filesize.

It's important to realize that upload_max_filesize is the sum of the sizes of all the files that you are uploading. post_max_size is the upload_max_filesize plus the sum of the lengths of all the other fields in the form plus any mime headers that the encoder might include. Since these fields are typically small you can often approximate the upload max size to the post max size.

memory_limit
When the PHP engine is handling an incoming POST it needs to keep some of the incoming data in memory. This directive has any effect only if you have used the –enable-memory-limit option at configuration time. Setting too high a value can be very dangerous because if several uploads are being handled concurrently all available memory will be used up and other unrelated scripts that consume a lot of memory might affect the whole server as well.

max_execution_time and max_input_time
These settings define the maximum lifetime of the script and the time that the script should spend accepting input. If several megabytes of data are being transferred max_input_time should be reasonably high. You can override the setting in the ini file for max_input_time.

Apache Settings
The Apache web server has a LimitRequestBody configuration directive that restricts the size of all POST data regardless of the web scripting language in use. Some RPM installations sets the limit request body to 512Kb. You will need to change this to a larger value or remove the entry altogether.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Similar topics (2)