In this thread some very helpful Moodlers (Helen Foster, Ray Lawrence, Tim Allen, and Iñaki Arenaza) helped me solve the problems I was experiencing when trying to increase the maximum allowed size for uploaded files in my server. At Helen's request, I've put together a little tutorial that summarizes what went on in that discussion and what I found out myself so that hopefully others won't have to spend as much time as I had to spend trying to figure out how to do things right.
Helen suggested that this should go to the FAQ in MoodleDocs Administration FAQ. Before I put it there, though, I thought I would post first a draft in the same forum where I requested help so that the people that helped me or perhaps others can have a look at it and make sure I got everything straight. Obviously I'm not a native speaker of English, either, so suggestions to improve the text and make it more clear are also very welcome. Once I get your feedback, I can add it to the official FAQ. This way we also help the dedicated people who manage the documentation section save some time.
== How do I increase the maximum size allowed for uploaded files? ==
Please, read first the answer to the question 'How do the limits on uploaded files work?' to place these instructions in their appropriate context.
are basically two methods:
Modifying the php.ini file
b) Modifying the .htaccess file
a) Modifying the php.ini file: locate the following strings and change the values
php_value post_max_size 20971520
Note: 20971520 would be the integer value for 20M of maximum allowed size in case you wanted to set the maximum to that size.
Modifying the .htaccess
The .htaccess file contains instructions that allow you to override the general default settings of your Apache server. Hence, you can, for instance, increase the upload size for your Moodle installation without affecting other applications.
you do not have one already, you need to create a file called
.htaccess in Moodle's main directory
that contains definitions for these settings. This only works on
Apache servers and only when Overrides have been allowed.
in order for the instructions in the .htaccess
file to take effect, the file httpd.conf
in your Apache installation must contain the following
Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
"/full path to your moodle directory">
the following overrides must be enabled:
AllowOverride controls what directives may be placed in .htaccess
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
default "AllowOverride" is set to none, which would mean
that the .htaccess file would not be enabled and would thus not work.
the appropriate Overrides are enabled, you need to make sure your
file contains something like the following:
Fourthly, sometimes Apache limits the size of uploaded files
### (this is a separate limit to the one in PHP, see below).
### The setting here turns off this limitation
These are optional - you may not want to override php.ini
### To enable them, remove the leading hash (#)
php_value post_max_size 20971520
20971520 would be the integer value for 20M of maximum allowed size
in case you wanted to set the maximum to that size.
Advantages and disadvantates of the two methods:
the appropriate .htaccess
file only affects moodle, and not all other PHP applications. Also,
if you only modify the .htaccess file, you won't need to restart the
php.ini, on the other hand, has
consequences for all PHP applications installed in the server and
always requires the Apache server to be restarted.
Thus, the .htaccess solution seems to be the most desirable alternative. Note, however, that if the httpd.conf has to be modified, you will also need to restart Apache for the changes to take effect. To restart Apache and to modify the httpd.conf file, you must have administrator/root privileges, but if the Overrides are already enabled, you can edit the .htaccess file yourself provided that you have write permissions in the relevant directory.