
File Management
Dealing with files in web-based applications is not always straightforward. While Moodle provides a user interface to perform this task, it is sometimes necessary that as the administrator, you will have to bypass this mechanism and use other means.
Moodle File Management Interface
Moodle offers a (very) basic file management interface that lets you upload, move, delete, and rename files and directories. From the web interface, you only have access the course folders in moodledata (or whatever has been specified in $CFG->dataroot)
. As described in the Code and Data Location section, you have access to the site folder (1) from the front page, and the folders 2, 3, 4, and so on from within the respective courses.

In the previous image, you will see a sample files area containing a directory (backupdata We will deal with this particular location in more detail in Chapter 12) and two files (School_Website-Policy.htm
and spec.zip)
. In addition to the name, its size, and the last modification timestamp, Moodle also displays context-sensitive actions (on the right) and icons (on the left) for each file and directory.
To select a file or directory, tick the box in the left most column. (Clicking on the name will open the file/directory.). There are buttons such as Select all and Deselect all for selecting and deselecting files. Once selected, a number of actions can be performed via the With chosen files... drop-down menu:
- Move to another folder: You have to select the new destination.
- Delete completely: This irreversible operation has to be confirmed first.
- Create a zip archive: You have to provide a name for the archive.
To create a new folder, press the Make a folder button. The name of the folder has to be unique in the directory in which it will be created.
The uploading of files takes place after pressing the Uploading this file button:

If you position the mouse pointer in the text field, or select the Browse... button, the standard file dialog of your local computer will be displayed from which you have to select the file to be uploaded.
Unfortunately, it is possible to upload only one file at a time. However, you can upload a compressed file in ZIP format, and then unzip it using the context-specific link that will appear beside the file. While this is not ideal, it resolves the problem when you have to upload multiple files. If you use this mechanism frequently, make sure the "Path to zip" is set in the System Paths settings (you can find details in Chapter 11 of how to do this). Moodle has its own internal zip and unzip functionality, but using this path allows Moodle to access the native operating system's zip and unzip functionality, which is generally fast and less prone to error.
Each site and course has an upload file limit. It is set to 2MB for the system referred to in the screenshot. If you have files larger than the limit, you will have to increase the limit.
If you have access to your server's php.ini
file, modify the following two lines where <value> represents the maximum limit (multiple formats are supported, for example, 20M or 20971520):
upload_max_filesize = <value> post_max_size = <value>
If you don't have access to the php.ini
file, create a .htaccess
file in your main Moodle directory and add the following two lines:
php_value upload_max_filesize = <value> php_value post_max_size = <value>
On some systems you will also have to increase the LimitRequestBody
parameter, usually found in the Apache configuration file httpd.conf
.
Alternatively, you can use other file management operations which we will cover next.
Web Host File Management
Most web hosts (for example, Cpanel and Plesk) offer a web interface that provides a file management facility. These interfaces allow you to upload files and directories in a more flexible way than using the simple Moodle file interface.
The advantages of using a web interface are:
- Ability to upload multiple files
- No upload limit
- More user-friendly interface than its Moodle counterpart, or any shell-based tools
The disadvantages of using a web interface are:
- File management is not very flexible
- Uploading large files will (still) be slow because they are copied over HTTP
File Management via FTP
When uploading large files via the Moodle interface or any other web browser-based facility, copying takes place over HTTP, which is by its nature very slow. An alternative is to use commands that use more efficient network protocols.
FTP is the best known command for transferring data from one computer to another through a network. This avoids the HTTP overhead and is significantly faster. Alternatively, you can use secure FTP (sFTP), which is more secure, but two to three times slower than the standard FTP. Some popular FTP clients are:
- gFTP (for Linux)
- WinSCP (Windows)
- Cyberduck (Mac OS X)
- FireFTP (Firefox plug-in)
- Built-in FTP clients in web authoring tools such as Adobe Dreamweaver
For very large files, such as high-quality learning resources, it is common to upload a large ZIP archive via FTP and then use the built-in zip link in the files' web interface to uncompress the archived files. Again, make sure the "Path to zip" is set in the System Paths settings to increase the speed. Be aware that you have to copy the files in the correct location. Use the directory structure explained previously as a reference.
File Management via WebDAV
WebDAV stands for Web-based Distributed Authoring and Versioning. According to its website (www.webdav.org), "It is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers."
In the context of Moodle, it allows you to configure the system in a way that the users can access the course files from a web folder. Web folders are similar to network drives and act like local drives on your PC or Mac. There are a number of advantages to using web folders:
- Drag and drop is fully supported to copy files from and to Moodle instead of the cumbersome file upload mechanism
- Multiple files can be copied to and from Moodle in a single operation
- The upload limit is being bypassed using web folders
- Files can be manipulated without opening Moodle in a web browser
- File upload is faster via WebDAV than the existing upload mechanism
- The mechanism works across operating systems
The DAV module has to be installed on your web server. On Apache it is called mod_dav. Furthermore, magic_quotes_gpc has to be disabled. For more information on setting up WebDAV, check http://docs.moodle.org/en/WebDAV_Setup.
The module only allows access to users who previously had access to course files, such as teachers with editing rights, and does not allow access to other users, such as students. Also, access is provided only to the course folders (including the site files folder); no Moodle system folders can be accessed.
Once WebDAV has been installed, you have to enable it in Moodle. Go to Server | WebDAV to modify its settings. The link only appears if your WebDAV server is working properly.
At the time of print, WebDAV was not yet included in the core of Moodle. To implement this powerful feature, you have to download a special WebDAV-enabled version (search for webdav-applyto19.patch
), or manually install the module from the contrib path of CVS (Concurrent Versioning System) repository.


Now that WebDAV has been enabled in Moodle, let's connect to it from a PC. The procedure is identical on other operating systems, but some are a bit temperamental when it comes to web folders or mount points. You will find further information on setting up WebDAV at http://www.webdavsystem.com/server/access.
Moodle controls the usage of WebDAV through the moodle/site:webdav
capability. By default, only the Course Creator role has this capability (besides you as the administrator, of course), that is, only the course creators are allowed to connect to Moodle via web folders. To permit other user types to use this powerful mechanism, you will have to modify their roles. To know more, please refer Chapter 6.
To access files from a course, navigate to the course files in a Moodle course. The standard files dialog now displays some WebDAV information at the top. If you use Windows Explorer, a clickable link is provided called Connect to Web Folder. If you use any other browser, copy the URL displayed and paste it in the address bar of your file manager:

The standard Windows dialog will be displayed to connect to network drives. Provide your Moodle user credentials (Username and Password) and tick the Remember my password box if you don't want to re-enter them the next time you connect to Moodle:

A standard Windows folder will open with your Moodle course files, which you can manipulate as normal. You can now drag and drop files from your PC into the Moodle Web folder. Your teachers will love this feature!

Alternatively, you can connect a Moodle folder as a network drive. This method will allow sharing of files containing all course folders named by their course's short name or ID number (depending on your Windows version) on the network.
When mapping a drive, click Sign up for online storage or connect to a network server (on Windows XP), and Connect to a website that you can use to store your documents and Pictures (on Windows Vista). Then select Choose another network location and provide the address given on the Moodle site files screen as well as the username and password.
Your Moodle files will now be mounted as a network drive in My Network Places. If even this doesn't work, you may be using a client other than Windows. Have a look at the WebDAV Connect site at http://docs.moodle.org/en/WebDAV_Connect for more information.