If its getting read as zip couldn't you just add "pptx" to the 
includes/mime.types file on the application/zip line?  This is how I get ppt to 
be recognized since it is read as "msword" and so I add "ppt" to the 
applications/msword line.

-Jim



-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Lane, Ryan
Sent: Friday, April 24, 2009 11:25 AM
To: MediaWiki announcements and site admin list
Subject: Re: [Mediawiki-l] power point upload?

> I attempted to load a MS Power Point 2007 file (.pptx) to my 
> wiki this afternoon, and I got the message that the file was 
> corrupt or the wrong file type.
> 
> I *did* set $wgFileExtensions array in LocalSettings.php to 
> allow .ppt/.pptx files; any ideas?
> 
> Oh, and thanks for all the answers to my first question about 
> a root installation! :)
> 

Office 2007 formats get detected as zip files. It is possible to upload
these without turning off MIME detection, but I'll tell you ahead of
time, this is a dirty, dirty hack:

--- MimeMagic.php.old   2009-04-24 10:20:58.000000000 -0500
+++ MimeMagic.php       2009-04-24 10:20:06.000000000 -0500
@@ -334,6 +334,14 @@
                $m = trim( $m );
                $m = preg_replace( '/\s.*$/', '', $m );
 
+               //BEGIN CUSTOMIZATION
+               if ( $ext == 'ppt' ) {
+                       $m = 'application/vnd.ms-powerpoint';
+               } else if ( $ext == 'xls' ) {
+                       $m = 'application/vnd.ms-excel';
+               }
+               //END CUSTOMIZATION
+
                return $m;
        }
 
@@ -547,6 +555,9 @@
                // Check for ZIP (before getimagesize)
                if ( strpos( $tail, "PK\x05\x06" ) !== false ) {
                        wfDebug( __METHOD__.": ZIP header present at end
of $file\n" );
+                       if ( $ext == 'docx' || $ext === false ) {
+                               return 'application/msword';
+                       }
                        return $this->detectZipType( $head );
                }

Note that the list or my email client probably slaughtered the diff.
You'll probably want to do this by hand. Notice that this only fixes
docx, so you'll need to do the rest, but this is a way to do it.

That said... Don't use Office 2007 formats. Either use Office 2003
formats, or use ODT.

If you want to fix the issues with the older office formats, see my blog
entry on it:

http://ryandlane.com/wprdl/2009/04/21/allowing-docpptxls-uploads-to-medi
awiki-and-getting-proper-mime-types-back/

V/r,

Ryan Lane

_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to