[Mediawiki-l] mime types

Lane, Ryan Ryan.Lane at ocean.navo.navy.mil
Tue Jan 29 22:17:18 UTC 2008


> See <
> http://www.mediawiki.org/wiki/Manual:Mime_type_detection#MIME_
> type_validation
> >.

Putting:

	application/msword doc xls ppt

works for getting the files into the wiki, but causes the wrong mime
types to be sent back when the user accesses the file.

What I've found to work (and please let me know if there is a better
way), is to send the correct mime type out depending on the extension:

--- MimeMagic.php.old   2008-01-29 16:15:59.000000000 -0600
+++ MimeMagic.php       2008-01-29 16:15:35.000000000 -0600
@@ -497,6 +497,21 @@
 
                }
 
+               //BEGIN CUSTOMIZATION
+               # New excel files have the same magic number as msword
files
+               if ( $mime == "application/msword" ) {
+                       $i = strrpos( $file, '.' );
+                       $e = strtolower( $i ? substr( $file, $i + 1 ) :
'' );
+
+                       if ( $e == "xls" ) {
+                               $mime= "application/vnd.ms-excel";
+                       }
+                       if ( $e == "ppt" ) {
+                               $mime= "application/vnd.ms-powerpoint";
+                       }
+               }
+               //END CUSTOMIZATION
+
                if ( isset( $this->mMimeTypeAliases[$mime] ) ) {
                        $mime = $this->mMimeTypeAliases[$mime];
                }



V/r,

Ryan Lane



More information about the MediaWiki-l mailing list