This is a known problem but I'm not sure where
Mediawiki.org is on fixing it or
whether they are attempting to fix it, though I have heard rumors of a fix in 1.17. The
problem stems from Microsoft (surprise!) having changed its format for Office 7 documents.
Its format gives its files a mime-type of a zip file, so when Mediawiki checks the file
it sees a docx extension but when it looks at the mime-type of the file (a binary string
near the beginning of the file) it sees what appears to be a zip file. Thus the
"corruption". These checks help prevent users from uploading malicious files
with innocent looking extensions, like uploading a nasty zip file with a jpg extension for
example.
You can turn off mime-type checking with a switch in LocalSettings.php:
$wgVerifyMimeType = false;
and then Mediawiki will just check the extension, docx, see that it is allowed and allow
the upload without checking the mime-type. Of course this also turns off a good security
function, so if you do this you should trust who is uploading documents to your wiki. In
my case, as a workaround, I ask users to email me when they want to upload Office 7 files,
I turn off mime-type checking, then after the upload turn it back on.
Now this gets the file uploaded but does not fix the problem because once uploaded your
docx file still looks like a zip file to Mediawiki, so if someone makes a link to the docx
file on a wiki page and someone on a PC clicks on the link, instead of their PC using Word
to open up the docx file you will have whatever opens up zip files come up, like WinZip.
Your users will need to download the file to their PCs to then open it in Word. And
saving docx files in "doc" format does not help. They still have a zip mime
type for some reason.
So, that is the long and short of it. Dealing with Office 7 documents uploaded to
mediawiki is problematic. Assuming these files are not being put there to be edited by
others (a bad method of document development anyway) I suggest having your users save
their files in PDF format. Then upload the PDF file to the wiki, which will avoid the
whole Office-7-zip-mime-type problem.
-Jim
-----Original Message-----
From: McHale, Nina [mailto:Nina.McHale@ucdenver.edu]
Sent: Thursday, March 10, 2011 1:49 PM
To: Haim (Howard) Roman; MediaWiki announcements and site admin list
Subject: Re: [Mediawiki-l] Uploading office docs
Haim and Ray, thanks so much for your responses! Very sorry I didn't include the error
message in my initial email, which is:
The file is corrupt or has an incorrect extension. Please check the file and upload
again.
And Ray, yes, sanity check checks out, file upload max is 40 MB, and all Office doc types
and extensions are allowed. :) I'm testing a very small file, an empty .docx file, to
no avail. Haim, thanks for sharing your alternative to this issue, which I will definitely
try if I can't resolve the issue.
Nina
Nina McHale, MA/MSLS
Assistant Professor, Web Librarian
University of Colorado, Auraria Library
Facebook & Twitter: ninermac
http://milehighbrarian.net
On 3/10/11 1:17 AM, "Haim (Howard) Roman" <roman(a)jct.ac.il> wrote:
Some file types are considered dangerous, and you need extra steps to allow them. And
this is something you normally shouldn't do. References:
*
http://www.mediawiki.org/wiki/Manual:$wgMimeTypeBlacklist
*
http://www.mediawiki.org/wiki/Manual:$wgFileBlacklist
*
http://www.mediawiki.org/wiki/Manual:Configuring_file_uploads#Configuring_f…
I set up a special directory for such files (I call it an "auxiliary" site).
They're web-accessible there. And I defined a template to build the correct URL to
point to that template. E.g.,
{{aux|a.doc|The DOC file version}}
Yields the string "The DOC file version" that is a link to
http://mysite.org/wiki-aux/a.doc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Haim (Howard) Roman
Computer Center, Jerusalem College of Technology
Phone: 052-8-592-599 (6022 from within Machon Lev)
On Thu, Mar 10, 2011 at 09:38, Raymond Wan <r.wan(a)aist.go.jp> wrote:
Hi Nina,
On Thu, Mar 10, 2011 at 12:37, McHale, Nina <Nina.McHale(a)ucdenver.edu> wrote:
I have been having trouble uploading Word and
PowerPoint documents to our wiki. I added the file types .doc, .docx, .ppt, and .pptx to
$wgFileExtensions in LocalSettings.php, and it appears as though others ARE able to upload
these types of files, because, well, they're there. This came up again because one
person wanted to upload a .docx file, and while he was able to upload .doc files, he did
not have any luck with .docx. I have not altered the mime.info <http://mime.info>
or mime.types files; I just looked over the documentation for that, but I'm not sure
that's the right place to be looking.
And I don't know if it makes a difference, but I'm using Safari/Firefox on a Mac,
and most others are using PCs with Firefox/IE.
I'm not entirely sure the cause of your problem, but I don't think the
browser would matter -- someone else can correct me.
So, when you go to "Upload file", .docx is listed as a possible
option. Just a sanity check to make sure $wgFileExtensions changes
are taken...
The other thing you might want to see is the size of the file that you
are uploading. There are size limits and maybe your .docx file just
happens to be larger than the ones that are already up there. Or
maybe they were uploaded at a time before a particular configuration
was changed; and maybe that change has now broken the upload process
some how.
What kind of error message do you get when you upload something? When
I was trying to configure uploads, putting the error message in Google
helped me find the solution. See for example the steps listed here:
http://www.mediawiki.org/wiki/Manual:Configuring_file_uploads
Hope this helps.
Ray
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l