
WordPress 最大文件
为了提高安全性,WordPress 允许您仅上传最常用的文件类型。您可以使用默认媒体上传器上传常用的图像格式、音频/视频和文档。但是如果您想上传不允许的文件类型怎么办?在本文中,我们将向您展示如何添加要在 WordPress 中上传的其他文件类型。
为了增加安全性,WordPress 允许您仅上传最常用的文件类型。您可以使用默认媒体上传器上传常用的图像格式、音频/视频和文档。但是,如果您想上传不允许的文件类型怎么办?在本文中,我们将向您展示如何添加其他文件类型以在 WordPress 中上传。

影片教学 (Video Tutorial)
如果您不喜欢该视频或需要更多说明,请继续阅读。
如果您不喜欢该视频或需要更多说明,请继续阅读。
WordPress中允许上传的文件类型 (File Types Allowed for Upload in WordPress)
WordPress allows you to upload most common image files, audio/ video, PDF, Microsoft office and OpenOffice documents. WordPress codex has a full list of 允许的文件类型 and extensions.
WordPress允许您上传最常见的图像文件,音频/视频,PDF,Microsoft Office和OpenOffice文档。 WordPress Codex包含允许的文件类型和扩展名的完整列表。
为其他文件类型添加例外 (Adding Exceptions for Additional File Types)
安全性是限制用户可以上传的文件类型的主要原因。然而,这并不意味着用户不能改变这一点。使用少量代码,您可以向 WordPress 添加新的文件类型和扩展名。
安全性是限制用户可以上传的文件类型的主要原因。但是,这并不意味着用户无法更改此设置。只需少量代码,您就可以向 WordPress 添加新的文件类型和扩展名。
For example, add this code in your theme’s 函数.php file or a 特定于站点的插件 to allow SVG file type to be uploaded:
例如,将此代码添加到主题的函数.php文件或具体的于在网站的插件中,以允许上传SVG文件类型:
function my_myme_types($mime_types){
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);
请注意,文件扩展名作为 $mime_types 关联数组中的键,而 mime 类型作为其值。
请注意,文件扩展名充当 $mime_types 关联数组中的键,mime 类型充当其值。
In this example, svg file extension represents files with the mime type 图像/svg+xml. You can find out mime types of several common file extensions on 这一页.
在此示例中,svg文件扩展名表示MIME类型为图像/svg + xml 文件 。 您可以在这一页上找到几种常见文件扩展名的mime类型。
您还可以在一个代码片段中添加多种文件类型,如下所示:
您还可以在一个代码片段中添加多种文件类型,如下所示:
function my_myme_types($mime_types){
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
$mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files
return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);

We hope this article helped you learn how to allow additional file types to be uploaded in WordPress. You may also want to take a look at how to 增加 WordPress 中的最大文件上传大小.
我们希望本文能帮助您学习如何允许在WordPress中上传其他文件类型。 您可能还想看看如何增加 WordPress 中的最大文件上传大小 。
If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and 谷歌+.
如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特和谷歌+上找到我们。
WordPress 最大文件