WordPress 插件记录

您会看到要添加文件类型,只需将扩展名添加到数组中,并将文件扩展名作为键,将mime类型作为值,.mobi格式文件的MIME类型application/x-mobipocket-ebook和.epub格式的MIME类型为application/epub+zip

来自 <https://qastack.cn/wordpress/42669/how-to-upload-and-allow-downloads-of-mobi-and-epub-formats>

  1. 修改您主机的.htaccess 内容,加上:

SetEnv PHPRC /刚才放置php.ini的目录

使用php.ini的方式,不一定所有虚拟主机都支持,所以若这招行不通,请连络您的主机商!

解决WordPress上传文件类型

WordPress有内置几种常见的文件格式,若不在内置名单中,则会有安全提示出现,然后不给上传。如果要扩充上传文件的类型,最轻型的作法是打开在主题目录中的 functions.php 加上一些code:

add_filter(‘upload_mimes’, ‘custom_upload_mimes’);
function custom_upload_mimes ( $existing_mimes=array() )
{
// Add file extension ‘extension’ with mime type ‘mime/type’
$existing_mimes[‘extension’] = ‘mime/type’;
// add as many as you like e.g.
$existing_mimes[
‘rar’] = ‘application/rar’; //增加rar类型文件
// remove items here if desired …
//unset( $existing_mimes[‘exe’] );
// and return the new full result
return $existing_mimes;
}

来自 <http://www.thefox.cn/wordpress-upload-problems.shtml>

function my_myme_types($mime_types){

$mime_types[‘svg’] = ‘image/svg+xml’; //Adding svg extension

$mime_types[‘epub’] = ‘application/epub+zip’; //Adding svg extension

$mime_types[‘mobi’] = ‘application/x-mobipocket-ebook’; //Adding svg extension

return $mime_types;

}

add_filter(‘upload_mimes’, ‘my_myme_types’, 1, 1);