Note: You are currently viewing documentation for Moodle 2.9. Up-to-date documentation for the latest stable version of Moodle may be available here: Jon Witts/file-upload-v2.

User:Jon Witts/file-upload-v2: Difference between revisions

From MoodleDocs
Line 71: Line 71:


===php.ini with hosted server===
===php.ini with hosted server===
Some servers will not allow you to change the moodle root .htaccess file and tell you to use a php.ini file for php directives.  Here you can use the instruction located in the section above called [[File_upload_size#Modifying_the_php.ini_file|Modifying the php.ini file]].
Some servers will not allow you to change the moodle root .htaccess file and will tell you to use a php.ini file for php directives.  The steps are basically the same as we covered above and your host will probably be running PHP 5.x
*Locate the key php file.  It probably will not be located with your Moodle code.
*Using a file edit program, change the upload max and post max size in the active php file.


Find the php.ini file in your moodle subfolder on your hosted server. You might want to copy the file as a backup just in case.  Edit php.ini, find "upload_max_filesize" and post_max_size in the code.  After the = change the number.  Here the max filesize is 20 megabytes.   
For example we found the following lines and the max file size is 20 megabytes.   


  upload_max_filesize = 20M
  upload_max_filesize = 20M
  post_max_size = 20M
  post_max_size = 20M
:Tip: Still not changed?  Some hosts using cpanel have a php config program under services/software.  Use the "Single php.ini" option and make sure you note the location of the php.ini file to modify.  This changes the .htaccess file in the same area and thus the server limit for all programs using php.

Revision as of 12:38, 9 March 2010

Probably the most frequently asked question in the Moodle.org Using Moodle forums is "How do I increase the upload file size limit?" This page will focus upon making changes in on the web server, outside of the Moodle interface.

There are different web server operating systems, thus the method of increasing the uploaded file limit can be different in each.

Overview

File Upload sizes are restricted in a number of different places. The list below shows the order of inheritance that file upload sizes follow.

  1. PHP Server level - File_upload_size (which is this page)
  2. Moodle site level - Site_policies
  3. Course level - Course_settings
  4. Activity level - Adding/editing_a_forum, Upload_a_single_file_assignment and Advanced_uploading_of_files_assignment

As you can see from the list above, it is the PHP server level that has the greatest precedence. So to increase the file upload size in Moodle we must first adjust this setting. Before we try to adjust any settings in PHP though it is good to know what is set already. We find this out by using a phpinfo script.

Locate the php file to modify

  • In PHP 4.x there must be a php.ini file in every directory that has php scripts.
  • In PHP 5.x there is only one php.ini file that is active. There maybe many php.ini files on the server, but only one will effect the file upload size. You can find this file by writing a php script or using the Moodle interface.

Moodle php info

In Moodle 1.7 onward, administrators run an information script by Site administration block>Server>PHP info will run an information script.

  • Configuration File (php.ini) Path show the location of the file.
  • Loaded Configuration File (if there) will over ride the above location.

Phpinfo script

For Moodles prior to 1.7 or on any server, you can create your own information page. Follow the instruction at phpinfo for more information.

At the very top of the phpinfo page you will see the version of PHP that your server is running. See the relevant section below for information on how to proceed.

What web server are you using?

Apache

If you are using an Apache web server you can use .htaccess files to over ride the php.ini settings, or you can edit the active php.ini files on your server.

IIS

.... edit php.ini ?! ...

Other

??

How is php running on your web server?

PHP can interact with other programs on your web server. If PHP is being controlled by an Apache Handler, you will have to restart your server. The changes will take place immediately if you are running API server using say CGI/FastCGI .

You can find out how your web server is running PHP by looking at:

  • Site administration>Server>PHP info "Server API"
  • phpinfo page: Apache2Handler > Loaded Modules Section.


??

What access do you have to the server?

To make changes to the main php.ini file you will need administrative access to the server...

Local / Full access to server

...

Shared / Hosted access to server

Hosted Server

Things can be a little different with a hosted server for uploaded and downloaded file size. You are probably going to to be told to create or change a .htaccess file, or to modify a php.ini file.

It might be a good idea to talk to with your service provider before you attempt anything. They probably have instructions on "how to" and may have their own limits for uploaded file size. Some hosts measure the file size in gigabytes and others in megabytes. If you are unhappy with their limits, then check your contract and consider changing your provider to one that has a limit and price that you like.

.htaccess with hosted server

The one purpose of an .htaccess file is to override the the current limitations of both the server and the php.ini file. Your hosted server should inform you where that file needs be placed in your Moodle, but generally in the root is sufficient. They may already have a standard file you can use, if so, use it - but perhaps not.

To the .htaccess file add the lines:

 php_value upload_max_filesize 128M
 php_value post_max_size 128M
 

This will limit uploads to 128MB, but you can make it any size you agree with your provider. The wording may vary slightly, according to the demands of the server.

php.ini with hosted server

Some servers will not allow you to change the moodle root .htaccess file and will tell you to use a php.ini file for php directives. The steps are basically the same as we covered above and your host will probably be running PHP 5.x

  • Locate the key php file. It probably will not be located with your Moodle code.
  • Using a file edit program, change the upload max and post max size in the active php file.

For example we found the following lines and the max file size is 20 megabytes.

upload_max_filesize = 20M
post_max_size = 20M