Manual:Configuring file uploads

MediaWiki supports uploading and integration of media files. This page describes the technical aspects of this feature, see Manual:Image Administration and Help:Images for general usage information.

Starting from MediaWiki version 1.1, uploads are initially disabled by default, due to security considerations. Uploads can be enabled via a configuration setting, although it is recommended that you check certain prerequisites first:

Make sure uploads are enabled in PHP
The following needs to be set in php.ini (which may be located somewhere like /etc/php/php.ini, /etc/php4/php.ini, /usr/local/lib/php.ini or on Win32 C:\Windows\php.ini):

file_uploads = on

If this is not set, no PHP scripts can use the upload functions, and MediaWiki's uploads will not be enabled.

Check Apache aliases
Some Apache configurations have the following alias set in httpd.conf:

Alias /images/ /usr/share/images/

If this is the case, either

or
 * remove this alias
 * change the upload directory to something else


 * How to test this? if you do not have access to the httpd.conf file of the web server?
 * Either ask your webserver admin or just try it, a commercial webhoster will have the above line disabled in most cases.

Check directory security
The upload directory needs to be configured so that it is not possible for an end user to upload and execute other scripts, which could then exploit access to your web directory and damage your wiki or web site.


 * Which unix security setting should this be? chmod 755? And on which ones on Windows?


 * The grandparent paragraph refers to the apache permissions: files uploaded should not be passed through the php interpreter (obvious reasons). The proper unix perms depend on who owns the upload dir, you have to make it writable to the apache process.

1.5 upwards
In MediaWiki version 1.5 and later, the attribute to be set resides in LocalSettings.php and is as follows:

$wgEnableUploads = true; # Enable uploads

This enables uploads, as one might expect. To disable them, set the attribute to false:

$wgEnableUploads = false; # Disable uploads

Pre-1.5
In older versions of the software, the attribute to be set resides in LocalSettings.php, but is backwards, i.e. $wgDisableUploads. The default is as shown:

$wgDisableUploads = true; # Disable uploads

Invert the value to enable uploads:

$wgDisableUploads = false; # Enable uploads

Configuring file types
You can add to $wgFileExtensions to allow uploads of any type of file you like. If not included then the $wgFileExtension line would look something like $wgFileExtensions = array('png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'pdf'); You can also set $wgStrictFileExtensions = false; to allow *any* type of file to be uploaded.

If you are getting the error "The file is corrupt or has an incorrect extension", make sure mime type detection is working properly.

If you decide to allow any kind of file, make sure your mime detection is working and think about enabling virus scans for uploads.

Thumbnailing
For information about automatic rendering/thumbnailing of images, see Manual:Image_thumbnailing

Set maximum size for file uploads
Per default, PHP allows uploaded files to be no more than 2 megabytes large. If you want to upload even larger files, change in the config file php.ini the post_max_size and upload_max_filesize  parameters. This requires root access to the server - if you are on a shared host, contact your server administrator.

MediaWiki issues a warning if you try to upload files larger than what is specified by $wgUploadSizeWarning option. This is independent of the hard limit imposed by PHP.