I submit to the Drupal comunity this compilation of info regarding the 2Mb PHP Upload limit. Could somebody with some Drupal/php expirence please check my notes. This is my first contribution:

Increasing Drupal/Upload's Maximum upload limit

2Mb PHP Upload Limit Audio Video <- my first attempt at SEO also.

To increase you’re sites upload limit editing the file php.ini and/or .htaccess is necessary.
[is this the right order to tell people to try? It sounds like .htaccess is ezer to deal with but seems like php.ini is more usefull ]

php.ini

*not all web hosts allow editing this file

According to the file itself:
This file controls many aspects of PHP's behavior. In order for PHP to read it, it must be named 'php.ini'. PHP looks for it in the current working directory, in the path designated by the environment variable PHPRC, and in the path that was defined in compile time (in that order).

The upshot is that you need a php.ini file in you're Drupal folder with the lines:

; Maximum size of POST data that PHP will accept.
post_max_size = xM

; Maximum allowed size for uploaded files.
upload_max_filesize = xM

Where x = twice the required upload size.

If you plan on using big files, a slow server or both, it may be necessary to change the max execution time.

max_execution_time = 60     ; Maximum execution time of each script, in seconds
max_input_time = 120	; Maximum amount of time each script may spend parsing request data [i uped this one without knowing why or being told to. is it nessicary?]

This can be done by copying a php.ini file from some other part of you’re site (i.e. the top folder, /etc/, or /php5/), finding and replacing the lines, then uploading it to you’re Drupal folder. If you are running a local server make sure to restart Apache. [would attaching a php INI-Recommended file, possibly with the edits be a good idea? ]

Failing that:

.htaccess

According to the Apace Documentation:
.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

This file should exist in you’re Drupal folder, but because of the dot at the beginning of the file name it may be hidden. Either way it needs to have these lines inserted at the bottom: [Before the ;end ?]

# increase upload limit for files
php_value upload_max_filesize xM
php_value post_max_size xM 

Same x as the php.ini file.

Don’t forget to restart Apache.

[ needs an ending summary ? or something ]

Other info:

A

php info file

can help you figure out which php.ini file is being used, or where to find one that can be coppied. [second half of that sentance bad advice ?]
A php info file consists of these lines: [is there a necessary file name ?]

<?php
phpinfo();
?>

Point you’re browser at the file and you should get a screenload of php related info. [is this right?]

Why on gods green earth dose x = 2*upload size ?

According to arthurf:
Drupal halves the value of post_max_size
$post_max = parse_size(ini_get('post_max_size')) / 2; (file.inc)

But According to siaiweb:
You are indeed limited to the half of your post_max_size (php.ini in your php folder) for every upload. That's a regular php rule, nothing odd here. It's for multi-upload purposes: none of your uploads can exceed half of the total allowed size

hooray for PHP: Hypertext Preprocessor minutia !
[there must be other more useful tips tricks etc that can be added here]
[is this correctly categorized as a 5.x issue? ]

Thanks

Thanks to all the people who responded to 2mb ‘error’ posts.

-Wolfang

Comments

cog.rusty’s picture

The limitation of an uploaded file to 50% of "post_max_size" is a Drupal precaution which was not effective and will be removed, at least in Drupal 6 and possibly in the next Drupal 5 release as well. See: http://drupal.org/node/104220

So, the advice should be:

upload_max_filesize
This is the maximum allowed size of an uploaded file.

post_max_size
This must be higher than upload_max_filesize to be able to upload a file of the maximum size. How much higher, a few bytes higher or 3 times higher or more, depends on whether more than one files are going to be uploaded in one post.

If your are using Drupal version 5.2 or older then you need to set this value to at least twice your upload_max_filesize (or higher), because of an additional Drupal safety check, which was intended to cover the case of two uploaded files of almost maximum size, but was causing confusion.

memory_limit
For the above to work, your memory_limit must be higher than your post_max_size.

For more details on these three php variables, see http://php.net/ini.core

TheCarrMan’s picture

What does or something mean? Needs an ending summary meaning I should put [ ? ] <---- that at the end or something? Should I replace the x with my own amount? Is this the only file I have to fix if I can't locate the php.ini file?

Either way it needs to have these lines inserted at the bottom: [Before the ;end ?]

# increase upload limit for files
php_value upload_max_filesize xM
php_value post_max_size xM

Same x as the php.ini file.

Don’t forget to restart Apache.

[ needs an ending summary ? or something ]