Jump to: navigation, search
This page is a translated version of the page Manual:$wgFileExtensions and the translation is 30% complete.

Other languages:
English • ‎español • ‎français • ‎italiano • ‎日本語 • ‎polski • ‎русский
Uploads: $wgFileExtensions
This is the list of preferred extensions for uploading files. このリストにない拡張子のファイルをアップロードすると警告が表示されます。
導入されたバージョン: 1.2.0
除去されたバージョン: 使用中
可能な値: 文字列の配列
既定値: array( 'png', 'gif', 'jpg', 'jpeg' );
他の設定: アルファベット順 | 機能順


$wgFileExtensions is the list of allowed/preferred extensions for uploading files in LocalSettings.phpManual:LocalSettings.php. ですが、$wgFileBlacklistManual:$wgFileBlacklist および $wgMimeTypeBlacklistManual:$wgMimeTypeBlacklist によって上書きされます。

If $wgStrictFileExtensionsManual:$wgStrictFileExtensions is set to true (default) then this $wgFileExtensions array is the list of allowed extensions, and all others are blocked.

If $wgStrictFileExtensionsManual:$wgStrictFileExtensions is set to false then users will only get a warning when uploading files with extensions not in this list. i.e. $wgFileExtensions is then only a preferred set of extensions. In this case some particularly dangerous file extensions will still be blocked using $wgFileBlacklist and $wgMimeTypeBlacklist.

If $wgCheckFileExtensionsManual:$wgCheckFileExtensions is false, this option has no effect since all file extensions will be permitted without performing any checks.

If $wgEnableUploadsManual:$wgEnableUploads is set to false, this option has no effect since all uploading is disallowed.

Some files, for example OpenDocument files (e.g. used by as odt, ods, odg, ...), use MIME types that don't match with their extension (or something similar). Uploading such files results in an error message like The file is corrupt or has an incorrect extension. Please check the file and upload again.. In such cases you can adjust the mapping of file extensions to mime types, see MIME type validation.


$wgFileExtensions is a php array, which is initialised with a default (sensible) set of file extensions. In LocalSettings.php you might use array operations such as...

// Add just one filetype to the default array
$wgFileExtensions[] = 'pdf';

// Add several file types to the default array
$wgFileExtensions = array_merge(
    $wgFileExtensions, array(
        'pdf', 'ppt', 'jp2', 'webp', 'doc','docx', 'xls', 'xlsx'

// Override the default with a bundle of filetypes:
$wgFileExtensions = array(
    'png', 'gif', 'jpg', 'jpeg', 'jp2', 'webp', 'ppt', 'pdf', 'psd',
    'mp3', 'xls', 'xlsx', 'swf', 'doc','docx', 'odt', 'odc', 'odp',
    'odg', 'mpp'