Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP / HTTPD Max File Size
#1
Thought this info may be of use to some people...

Quote:The maximum file upload size will depend on a number of factors.

1. Your server configuration (php.ini, apache version, php version etc, hardware and network connectivity), and
2. Your client-to-server bandwidth connection.

For the most part, you can control the ability of uploading LARGE (>8mb files) by modification of your php.ini file. However, your modifications will likely go beyond simply tweeking the "upload_max_filesize" variable.

Here's the php.ini modifications get an 11mb+ upload to function:

upload_max_filesize = 20M ; DEFAULT is 2M
max_execution_time = 300 ; DEFAULT is 30 [seconds]
post_max_size = 12M ; DEFAULT is 8M

You may also find it necessary to modify the "memory_limit" Resource Limit.

In order to get a 3MB upload to work, you only have to modify the upload_max_filesize variable. However, file uploads may fail because of script timeouts (exceeding max_execution_time) if you've got a poor network connection between your client and server.

Please remember to restart Apache after making modifications to php.ini.

Web Server Limitations

In the file httpd/conf.d/php.conf check the following:

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 524288
<Files>





Quote:File upload sizes are restricted in a number of ways - each one in the list restricts the following ones.

1. Firstly, there is a setting in Apache 2 which you may need to change. On Redhat this setting is very low by default, you can change the limit by adding or editing a line in Apache's /etc/httpd/conf/httpd.conf and/or /etc/httpd/conf.d/php.conf with the upload size in bytes (different operating systems may have these files in different locations):

LimitRequestBody 10485760

2. PHP also has two more byte limits, which you can set in php.ini and sometimes in a .htaccess file:

php_value upload_max_filesize 50000000
php_value post_max_size 50000000



Quote:Howto optimize your PHP installation to handle large file uploads.

Though PHP presents a very versatile and user friendly interface for handling file uploads, the default installation is not geared for working with files in excess of 2 Mega Bytes. This article will help you configure your PHP engine for handling such large file transfers.

The php.ini File


All the configuration settings for your installation are contained in the php.ini file. Sometimes these setting might be overridden by directives in apache .htaccess files or even with in the scripts themselves. However you cannot over ride the settings that effect file uploads with .htaccess directives in this way. So let's just concentrate on the ini file.

You can call the phpinfo() function to find the location of your php.ini file, it will also tell you the current values for the following settings that we need to modify


  • file_uploads
  • upload_max_filesize
  • max_input_time
  • memory_limit
  • max_execution_time
  • post_max_size
The first one is fairly obvious if you set this off, uploading is disabled for your installation. We will cover the rest of the configuration settings in detail below.


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.

According to the PHP documentation you can set a MAX_UPLOAD_LIMIT in your HTML form to suggest a limit to the browser. Our understanding is that browsers totally ignore this directive and the only solution that can impose such a client side restriction is our own Rad Upload Applet


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 effect the whole server as well.
max_execution_time and max_input_time

These settings define the maximum life time of the script and the time that the script should spend in accepting input. If several mega bytes of data are being transfered max_input_time should be reasonably high. You can override the setting in the ini file for max_input_time by calling the set_time_limit() function in your scripts.


Additonal Comments


Apache Settings

The apache webserver 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 limit request body to 512Kb. You will need to change this to a larger value or remove the entry altogether.


Other Options

If you expect to handle a large number of concurrent file transfers on your website consider using a perl or java server side component. PHP happens to be our favourite web programming language as well but perl and Java are just slightly ahead when it comes to file upload.

Most installations of perl as an apache module can accept in excess of 32 megabytes out of the box. Compare this against the 2MB default for PHP. The downside is that perl coding takes just a bit more effort than PHP but it's worth it.



Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Changing File Attributes and other Settings The Mob 0 436 01-25-2009, 10:48 AM
Last Post: The Mob
  Problem with an image file hellsing293 1 259 02-22-2008, 09:14 AM
Last Post: jedimaster86
  d2speech.mpq file brokended :( shadowkin 4 2,102 12-11-2007, 12:39 AM
Last Post: FeNiXSuNfIrE
  Railroad Tycoon 3 File needed... Siluru 2 464 11-21-2007, 04:43 PM
Last Post: Siluru
  .pdf file to .doc file itsjustme 9 358 11-16-2007, 09:25 PM
Last Post: Juke
  Someone please decompile this file and check for keyloggers. Joshy 25 715 03-27-2007, 08:16 AM
Last Post: Dan
  what is configure.ini file? gulerodden 2 231 12-25-2006, 01:12 AM
Last Post: SilverTears
  How-to-use a .iso File SilverTears 3 195 11-23-2006, 08:47 AM
Last Post: schmidz
  I have a corrupt file help me zazzi555 11 687 11-13-2006, 06:49 PM
Last Post: trayne
  Taking out parts of audio file? hellsing293 4 183 07-13-2006, 07:30 AM
Last Post: hellsing293

Forum Jump:


Users browsing this thread: 1 Guest(s)