Uploading Files
Uploading Files
MediaWiki allows users to upload images, documents, and other media files for use within wiki pages. This guide explains how to enable uploads and how to properly insert files into pages.
Enabling File Uploads (Administrators)
If you manage the wiki, make sure uploads are enabled in LocalSettings.php:
<syntaxhighlight lang="php"> $wgEnableUploads = true; $wgFileExtensions = [ 'png', 'jpg', 'jpeg', 'gif', 'pdf', 'svg', 'webp' ]; $wgMaxUploadSize = 10485760; // 10MB </syntaxhighlight>
Ensure the /images directory is writable by the web server.
You may also need to allow user permissions:
<syntaxhighlight lang="php"> $wgGroupPermissions['user']['upload'] = true; $wgGroupPermissions['autoconfirmed']['upload'] = true; $wgGroupPermissions['user']['reupload'] = true; $wgGroupPermissions['user']['reupload-own'] = true; </syntaxhighlight>
Uploading a File
- Log in to your account.
- Navigate to Special:Upload.
- Click Choose File.
- Enter a destination filename.
- Add a description and licensing information.
- Click Upload file.
After uploading, the file will be available at:
File:Filename.ext
Using Uploaded Files in Pages
Display an Image
<syntaxhighlight lang="wiki">
</syntaxhighlight>
Display Without Thumbnail
<syntaxhighlight lang="wiki"> File:Example.jpg </syntaxhighlight>
Link to a PDF or Document
<syntaxhighlight lang="wiki"> File:Document.pdf </syntaxhighlight>
To create a direct link:
<syntaxhighlight lang="wiki"> File:document.pdf </syntaxhighlight>
Allowing Additional File Types
To allow additional formats:
<syntaxhighlight lang="php"> $wgFileExtensions[] = 'svg'; $wgFileExtensions[] = 'webp'; </syntaxhighlight>
To disable strict file extension checking:
<syntaxhighlight lang="php"> $wgStrictFileExtensions = false; </syntaxhighlight>
Troubleshooting
| Problem | Solution |
|---|---|
| Upload option missing | Ensure $wgEnableUploads = true;
|
| File type not allowed | Add the extension to $wgFileExtensions
|
| Permission denied | Check folder permissions on the /images directory
|
| File too large | Increase $wgMaxUploadSize and PHP upload_max_filesize
|