Thursday, 08 October 2009 14:13
The Error: This file contains HTML or script code that may be erroneously interpreted by a web browser
This is a common error when uploading files that the MediaWiki system does not allow. By making some minor changes to the MediaWiki LocalSettings.php file, we can fix this.
For demo purposes, I'm going to make our system recognize SWF files (by default these are disallowed):
Firstly:
Add the following line to somewhere in the LocalSettings.php file in the web root folder where your MediaWiki is installed:
$wgFileExtensions[] = 'swf';
or if you already have an array, just add it to the end:
$wgFileExtensions = array('png', 'gif', 'jpg', 'jpeg', 'doc', 'ppt', 'xls', 'mpp', 'pdf', 'zip', 'flv', 'swf');
Online forums are saying this is it, but my system still didn't allow them and returned the above error...
Secondly:
Edit your /includes/specials/SpecialUpload.php file and add the following line shortly after the declaration of detectScript function:
if ($extension === 'swf') return false;
I put it straight after:
function detectScript($file, $mime, $extension) {
global $wgAllowTitlesInSVG;
...
# for debug purposes
error_reporting(E_ALL);
ini_set("display_errors", 1);
$wgShowExceptionDetails = true;
$wgShowSQLErrors = true;
$wgDebugDumpSql = true;
$wgDebugLogFile = '/var/www/html/debug_log.txt';
I still couldn't upload SWF files despite following all the information on the Internet. Ultimately I fixed this by a worrying fix...: modify /includes/MimeMagic.php under the line 434 "function doGuessMimeType()
function doGuessMimeType( $file, $ext = true ) {
return "application/x-shockwave-flash";
Of course this means that any mime types it's not sure about, it will return as shockwave files. This could be a security concern but as our MediaWiki is on our Intranet for Staff use only, it isn't.
| < Prev | Next > |
|---|


