简体   繁体   English

为媒体添加新的MIME类型

[英]Add new mime type for media

I want to upload some dfxp files to media by this code: 我想通过此代码将一些dfxp文件上传到媒体:

if ( !function_exists('media_handle_upload') ) {
    require_once(ABSPATH . "wp-admin" . '/includes/image.php');
    require_once(ABSPATH . "wp-admin" . '/includes/file.php');
    require_once(ABSPATH . "wp-admin" . '/includes/media.php');
}



  $id = media_handle_sideload(array('name' =>'test.dfxp', 'tmp_name' =>****/test.dfxp' ));

But I get this error: 但是我得到这个错误:

Sorry, this file type is not permitted for security reasons.

even when I put this function above the code to add the mime type: 即使我将此函数放在代码上方以添加mime类型:

function custom_upload_mimes( $existing_mimes ) {
    // add webm to the list of mime types
    $existing_mimes['dfxp'] = 'application/dfxp';
    // return the array back to the function with our added mime type
    return $existing_mimes;
}
add_filter('upload_mimes', 'custom_upload_mimes');

And Yes I checked the mimes and I found it. 是的,我检查了哑剧并找到了。

How can I solve this ? 我该如何解决?

I don't think there is mime type called 'application/dfxp' try this 我不认为有一种称为'application / dfxp'的mime类型,请尝试此操作

$existing_mimes['dfxp'] = 'application/xml';

insted of 装的

$existing_mimes['dfxp'] = 'application/dfxp';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM