Manual talk:$wgFileExtensions

From mediawiki.org
Latest comment: 10 years ago by 88.130.106.48 in topic Case sensitive?

File Type Errors[edit]

I can upload xls files but not doc files. The exact error message is: "".doc" is an unwanted file type List of allowed file types: gif, jpg, xls, pdf". I've tried turning of strict extensions, mime detection, and more... Nothing I've tried seems to allow them. I've also noticed the list of allowed filetypes never changes. Any ideas? -- Shannon_Lowder


I have done this... and the 'ppt' and 'xls' do not work. All others in the array do work. What is wrong?

I am having the same problem as cody is in regards to 'xls' files. It's CLEARLY in the array, and other files in the array work just fine. Attempting to upload .xls files results in "The file is corrupt or has an incorrect extension. Please check the file and upload again." Does anyone have any suggestions? Thanks! Giania@gmail.com
Answer: This is most probably due to the mime type checking - look at Manual:Mime type detection and see if your answer is there.

Uploading ods file[edit]

I am trying to upload an ods file. I have set the mime types for the file in mime.types. But on uploading an ods file why is media wiki recognizing it as a zip file? Any suggestions?

Upload exe-files[edit]

I can't enable the file upload of exe-files. I added the fileextension ("exe" and even ".exe"), and looked for the file-size in php.ini

Answer: exe are listed in $wgFileBlacklist. To allow 'exe' uploads you must remove 'exe' from the blacklist in addition to the changes you normally need to make (ie, "$wgFileExtensions[] = 'exe';").

Description page for PDF Files is not visible / empty[edit]

? Any Hints ?

THX, Heinz

Possibly a PHP error; activate error logging to check that in more detail. --88.130.106.48 22:27, 18 August 2013 (UTC)Reply

Needs Updating[edit]

This page is very un-clear about what the default values are for recent versions of the software.

Say you want to enable *.mp3 or *.mov files for uploading, simply add something like:
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'mp3', 'pdf', 'doc', 'mov', 'zip')
and make sure no other extension lines oppose that (such as $wgStrictFileExtensions, both on true and false) and that will work. It works fine for me anyway :) --87.69.58.71 12:15, 28 October 2006 (UTC)Reply

Old defaults[edit]

The default settings listed for old versions are correct, contrary to the recent edit summary by Hoggwild5. You may have all the old versions of MediaWiki, but you clearly haven't looked at them (just one example). Perhaps if you have some spare time you could check out more recent versions and fill in the defaults, as per the above request. --HappyDog 23:18, 12 June 2007 (UTC)Reply

I have no problem owning errors. Thanks for pointing this out. My bad. --Hoggwild5 19:47, 14 December 2007 (UTC)Reply

What file is this variable in?[edit]

Which file is this variable located in? LocalSettings.php?

All configuration options go into LocalSettings.php. That doesn't mean all are there from the start. But you can add them. See Manual:LocalSettings.php and Manual:Configuration settings -- Duesentrieb ⇌ 21:37, 24 October 2007 (UTC)Reply

Case sensitive?[edit]

I got a list of extensions from a project manager, put them into array format and put them in the config. They were uppercase and I didn't think anything of it, until uploading '.pdf' didn't work, but '.PDF' did. I changed them all to lower case and now can upload both .pdf and .PDF. It might be worth a mention in the documentation though. --Cm 12:45, 6 November 2009 (UTC)Reply

This behaviour is a bug in MediaWiki, which should be fixed. --88.130.106.48 22:30, 18 August 2013 (UTC)Reply

$wgextension default not an array, perhaps doesn't exist sometimes, limits choices of methods[edit]

I'm using MW 1.15.1. After adding the line

$wgFileExtensions = array_merge( $wgFileExtensions, array( 'pdf', 'svg' ) );

to my LocalSettings.php file, I sometimes got the PHP error:

Warning: array_merge()...Argument #1 is not an array...

There is no other instance of $wgFileExtensions in my LocalSettings file, and I put it near the end of the file. So, on some pageloads, it appears that the code doesn't declare the array. Therefore, it is not proper to use the arraymerge method listed on this help page. Instead, we should use the PHP method that works either way:

$wgFileExtensions[] = 'pdf';

-- (shawn) 66.67.97.102 18:50, 17 December 2009 (UTC)Reply

Files without extensions (hack)[edit]

To allow uploading of files that don't have extensions, you will need to apply the following hack: Edit $IP/includes/SpecialUpload.php and at line 351 (in version 1.11.1), change

  if ($finalExt == '') {
      return $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) );

to

  if ($finalExt == '') {
  /*  return $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) );   */

In other words, comment out the action that is taken if there's no file extension.

in newer MediaWiki versions (>= 1.11.2) you also have to do additional modifications in $IP/includes/SpecialUpload.php

Warning Warning: Remember this is only an untested hack. This will disable the Mime Type check for all files without an extension!

change (around line 1023)

  if ($wgVerifyMimeType) {

to

  if ($wgVerifyMimeType && $extension != '') {

to suppress the warning on the upload dialog add following line to your LocalSettings.php:

  $wgFileExtensions[] = '';

stl file upload not an array error[edit]

Getting a similar error to the above posted by (shawn) when adding file types to $wgFileExtensions it seems to object to the stl file type does not occur for any other type of file I have added to file extensions

[Wk7LrK3suHYAAHRcXGgAAAAC] /index.php?title=File:3DBenchycargobox.stl TypeError from line 164 of /home/username/sample.com/includes/shell/Command.php: Argument 1 passed to MediaWiki\Shell\Command::environment() must be of the type array, null given, called in /home/username/sample.com/includes/GlobalFunctions.php on line 2303

Need for PBIX extension, Mediawiki bug[edit]

pbix power bi is not zip file. Even with it into the $wgFileExtensions list,