How to Increase Maximum File Upload Size and allow PDF Uploads in MediaWiki

Updated on September 1, 2017

By default, MediaWiki allows user to upload jpg, png, ogg and tiff files that are up to 2MB in size. However, if you wish to upload other file formats such as PDF, PPT, DOC etc…then here’s how you can do that. Moreover, you need to increase maximum file upload size as well (to support larger PDF, DOC, PPT files).

Increase maximum file upload size

MediaWiki relies on PHP to limit the file upload size. It means, you need to check if PHP has file uploads turned on in ‘php.ini‘ file as below:

file_uploads = On

To increase maximum file upload size, make sure you make changes as below properties in php.ini

upload_max_filesize = 20M
post_max_size = 20M

The files will be uploaded to ‘images‘ directory under wiki root directory, which should have permission for the web server user.

sudo chown -R apache:apache images/

Mediawiki increase upload size

Enable or disable File uploads in MediaWiki

Now the PHP server supports file upload, but you can also control the upload feature in MediaWiki as well. To do that, edit ‘LocalSettings.php‘ and modify the below property.

#To enable Uploads
$wgEnableUploads = true;
#To disable Uploads
$wgEnableUploads = false;

Enable Uploads of PDF, DOC, PPT etc…

Edit ‘LocalSettings.php‘ and add the below line.

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc',
 'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx',
 'pptx', 'ps', 'odt', 'ods', 'odp', 'odg'
 );

Note for the extensions that should be allowed. For security reasons, .exe is not allowed in MediaWiki.

That’s it. Checkout other articles on MediaWiki here.

Was this article helpful?

Related Articles

Leave a Comment