You are here Home > Know-how > MediaWiki - CMS > Reference Tips & Tricks > File Uploads
MediaWiki - CMS
 

4.4 File Uploads

15.06.2007
4.3 Inline HTML [  up  ] - [ A - Z ] - [ top ] 4.4.1 How do I enable upload HTML files?

Enable file uploading

vi LocalSettings.php

$wgEnableUploads                = true;

includes/DefaultSettings.php (~1016)
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'pdf' );


Important   If uploading of MS Word documents does not work

«Upload warning ".doc.doc" is not a recommended image file format.»


Add doc to this list in includes/MimeMagic.php


 /** Defines a set of well known mime types
 * This is used as a fallback to mime.types files.
 * An extensive list of well known mime types is provided by
 * the file mime.types in the includes directory.
 */
define('MM_WELL_KNOWN_MIME_TYPES',<<<END_STRING
application/ogg ogg ogm
application/pdf pdf
application/x-javascript js
application/x-shockwave-flash swf
audio/midi mid midi kar
audio/mpeg mpga mpa mp2 mp3
audio/x-aiff aif aiff aifc
audio/x-wav wav
audio/ogg ogg
image/x-bmp bmp
image/gif gif
image/jpeg jpeg jpg jpe
image/png png
image/svg+xml svg
image/tiff tiff tif
text/plain txt doc
text/html html htm
video/ogg ogm ogg
video/mpeg mpg mpeg
END_STRING
);

This might be a bug in MediaWiki

I have added these lines into includes/Image.php as well so the Mime Type is stored accurately. Uploading of "*.doc" files works without this patch but is nice to see the correct Mime Type on the Wiki page ;-)

# diff Image.php bak/Image_bak1.php
1304,1310d1303
<
<               # X
<               if ($this->extension == 'doc') {
<                       $major = 'application';
<                       $minor = 'msword';
<               }
<               # /X
                $dbw->insert( 'image',
                        array(
                                'img_name' => $this->name,
                                'img_size'=> $this->size,
                                'img_width' => IntVal( $this->width ),
                                'img_height' => IntVal( $this->height ),
                                'img_bits' => $this->bits,
                                'img_media_type' => $this->type,
                                'img_major_mime' => $major,
                                'img_minor_mime' => $minor

Upload HTML pages in MediaWiki

SpecialUpload.php Function: detectScript($file,$mime)

$tags = array(
                        '<body',
                        '<head',
                        # X '<html',   #also in safari
                        '<img',
                        '<pre',
                        '<script', #also in safari
                        '<table',
                        '<title'   #also in safari
                        );

Images and files in the database

mysql> select img_name, img_major_mime,img_minor_mime from sunri_image;
+----------------------------------------+----------------+----------------+
| img_name                               | img_major_mime | img_minor_mime |
+----------------------------------------+----------------+----------------+
| 13608sma2.jpg                          | image          | jpeg           |
| Bestellformular_privat_Handy_d.doc.doc | text           | plain          |
+----------------------------------------+----------------+----------------+
2 rows in set (0.00 sec)



See also:
Upload large files


4.3 Inline HTML       A - Z Index       Top       Disclaimer       4.4.1 How do I enable upload HTML files?


$Id: uploading.html,v 1.124 2007/06/15 11:49:14 webcms Exp $
copyright © 2005-2007 by reto