Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: File upload size.

File upload size: Difference between revisions

From MoodleDocs
Line 54: Line 54:
The following instructions will only work on an Apache web server, and also the Apache server must have Overrides allowed.
The following instructions will only work on an Apache web server, and also the Apache server must have Overrides allowed.


Create a file called .htaccess in Moodle's main directory.
Create a file called .htaccess in Moodle's main directory that contains teh following information:


For the instructions in the .htaccess file to take effect, the file httpd.conf in your Apache installation must contain the following lines:
:</Directory>
::# 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
::# below.
:<Directory "/full path to your moodle directory">
And the following overrides must be enabled:
::# AllowOverride controls what directives may be placed in .htaccess files.
::# It can be "All", "None", or any combination of the keywords:
::# Options FileInfo AuthConfig Limit
:AllowOverride Options Indexes
By default "AllowOverride" is set to none, which would mean that the .htaccess file would not be enabled and would thus not work.
Once the appropriate Overrides are enabled, you need to make sure your .htaccess file contains something like the following:
::LimitRequestBody 0
::php_value upload_max_filesize 20971520
::php_value upload_max_filesize 20971520
::php_value post_max_size 20971520
::php_value post_max_size 20971520

Revision as of 16:07, 18 September 2009

Probably the most frequently asked question in the Moodle.org Using Moodle forums is "How do I increase the upload file size limit?"

Physical access to Server

These instructions assume you have full physical and administrative access to your server. If you are using a hosted server then you will probably need to look into other ways to increase your file upload size.

Modifying the php.ini file

These instructions show you how to change the file upload size by editing your php.ini file.

Ubuntu Linux Instructions

These instructions assume that you have installed PHP 5 and Apache 2 via apt-get and left it all as a default install. If you have compiled yourself I presume that you will know where your php.ini files are!

You need to edit the following three settings in your php.ini file located at: /etc/php5/apache2/

  • Type "sudo nano /etc/php5/apache2/php.ini"
  • Press Ctrl and W and type "post_max_size"
  • Change the value to the number of Mb you want your site to accept as uploads
  • Press Ctrl and W and type "upload_max_filesize"
  • Change the value to the number of Mb you want your site to accept as uploads
  • Press Ctrl and W and type "max_execution_time"
  • Change the value to 600
  • Press Ctrl and O
  • Press Ctrl and X
  • Type sudo /etc/init.d/apache2 restart

Your new file size limit should now appear in Administration > Security > Site Policies > Maximum uploaded file size

Windows XP and Server 2003 Instructions

These instructions presume that you have downloaded the latest PHP 5.2.x Windows zip package and extracted it to C:\PHP. If you have installed PHP to another location then change all references to "C:\PHP" to the location you installed PHP too.

  • Open C:\PHP
  • Right Click the php.ini file in this folder and choose "Open with..."
  • Choose "Wordpad" not "Notepad" to open the file with
  • Press Ctrl and F and type "post_max_size"
  • Change the value to the number of Mb you want your site to accept as uploads
  • Press Ctrl and F and type "upload_max_filesize"
  • Change the value to the number of Mb you want your site to accept as uploads
  • Press Ctrl and F and type "max_execution_time"
  • Change the value to 600
  • Press Ctrl and S
  • Exit Wordpad
  • Restart your webserver
    • For IIS
    • Open your Start Menu on your server and select "Run"
    • Type "iisreset /RESTART"
    • For Apache 2
    • The following command will work as long as you have installed Apache 2 as a service on your Windows Server
    • Open your Start Menu on your server and select "Run"
    • Type "httpd -k restart"

Your new file size limit should now appear in Administration > Security > Site Policies > Maximum uploaded file size

Modifying the .htaccess file

The following instructions will only work on an Apache web server, and also the Apache server must have Overrides allowed.

Create a file called .htaccess in Moodle's main directory that contains teh following information:

php_value upload_max_filesize 20971520
php_value post_max_size 20971520
php_value max_execution_time 600

Note: 20971520 would be the integer value for 20M of maximum allowed size in case you wanted to set the maximum to that size.

Hosted Server


See Also