Manual:$wgFileExtensions/zh

From Linux Web Expert

Revision as of 07:18, 7 March 2024 by imported>FuzzyBot (Updating to match new version of source page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<translate> Files and file uploads</translate>: $wgFileExtensions
这是上传文件的首选扩展的列表 上传不在此列表中的扩展名的文件将触发警告
<translate> Introduced in version:</translate>1.2.0
<translate> Removed in version:</translate><translate> still in use</translate>
<translate> Allowed values:</translate>(-{zh-hans:字符串数组; zh-hant:字串陣列;}-)
<translate> Default value:</translate>参见下方

详情

$wgFileExtensions是在LocalSettings.php 上传文件的首选扩展的列表 这是比$wgProhibitedFileExtensions $wgMimeTypeExclusions 更重要的

如果$wgStrictFileExtensions 被设置成功,这样$wgFileExtensions的列表是被允许的扩展,并且其他的全部都是被封禁的。

如果$wgStrictFileExtensions 被设置失败,这样用户在上传界面的时候将只有得到一个关于扩展不在支持列表的警告 即$wgFileExtensions是后续唯一一个完美的扩展设置 在这种情况下一些特别的危险文件扩展将会仍然被屏蔽用$wgFileBlacklist和$wgMimeTypeBlacklist

如果$wgCheckFileExtensions 是失败的,功能是没有影响的,因为所有文件扩展将会被信任而不会执行任何检查

如果$wgEnableUploads 设置失败,功能是无效的,因为所有的上传都是无效的。

Some files, for example OpenDocument files (e.g. used by OpenOffice.org 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.

默认值

MediaWiki版本:
<translate> ≥</translate> 1.27
$wgFileExtensions = [ 'png', 'gif', 'jpg', 'jpeg', 'webp', ];
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.26</tvar> is unsupported version</translate>">
1.3 – 1.26
<translate> MediaWiki versions:</translate>
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg' );
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.2</tvar> is unsupported version</translate>">
1.2
MediaWiki版本:
$wgFileExtensions = array( "png", "jpg", "jpeg", "ogg" );

-{zh-hans:示例; zh-hant:範例;}-

$wgFileExtensions是一个php数组,被初始化的默认文件扩展 在LocalSettings.php,你可能用数组操作例如...

// 添加仅仅一个文件类型到默认数组
$wgFileExtensions[] = 'pdf';

// 添加许多文件扩展到默认数组中
$wgFileExtensions = array_merge(
    $wgFileExtensions, [
        'pdf', 'ppt', 'jp2', 'doc', 'docx', 'xls', 'xlsx'
    ]
);

// Override the default with a bundle of filetypes:
// This is usually not a good idea because newer important file extensions could be added in the defaults in later versions of MediaWiki.
$wgFileExtensions = [
    'png', 'gif', 'jpg', 'jpeg', 'jp2', 'webp', 'ppt', 'pdf', 'psd',
    'mp3', 'xls', 'xlsx', 'swf', 'doc', 'docx', 'odt', 'odc', 'odp',
    'odg', 'mpp', 'pptx'
];

参见