Hi, all,
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! :)
Nina
Nina McHale, MA/MSLS Assistant Professor, Web Librarian Auraria Library http://library.auraria.edu/~nmchale/ Facebookhttp://www.facebook.com/profile.php?id=672599042 | MySpacehttp://www.myspace.com/ninermac Serving the University of Colorado Denver, Metropolitan State College of Denver, and the Community College of Denver 1100 Lawrence Street Denver, CO 80204 303-556-4729
Try adding the following to your LocalSettings.php:
$wgVerifyMimeType = false;
IIRC Apache2 doesn't "get" the new Office 2007 (MIME) file formats correctly.
-Jon
On Thu, Apr 23, 2009 at 16:01, McHale, Nina Nina.McHale@ucdenver.eduwrote:
Hi, all,
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! :)
Nina
Nina McHale, MA/MSLS Assistant Professor, Web Librarian Auraria Library http://library.auraria.edu/~nmchale/http://library.auraria.edu/%7Enmchale/ Facebookhttp://www.facebook.com/profile.php?id=672599042 | MySpace< http://www.myspace.com/ninermac%3E Serving the University of Colorado Denver, Metropolitan State College of Denver, and the Community College of Denver 1100 Lawrence Street Denver, CO 80204 303-556-4729
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
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
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: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] 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 MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
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.
No. MediaWiki rejects zip MIME type uploads (for good reason). The (incomplete) hack in my previous email still blocks most zip files from being uploaded. Zip files without extensions can probably be uploaded because of the "$ext === false" check though (I didn't test for this).
For some reason MediaWiki checks the MIME type twice; once with the extension passed to the function, and another time without the extension passed. The "$ext === false" part was required to get around that. Is this how the checks are *really* supposed to work? I really didn't understand that; why check twice?
V/r,
Ryan Lane
mediawiki-l@lists.wikimedia.org