我想通过以下代码将一些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' ));
但是我收到了这个错误:
Sorry, this file type is not permitted for security reasons.
即使我把这个函数放在代码上面来添加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');
是的我检查了哑剧,我找到了它。
我该如何解决这个问题?
答案 0 :(得分:0)
我不认为有mime类型叫做“app / dfxp'试试这个
$existing_mimes['dfxp'] = 'application/xml';
insted of
$existing_mimes['dfxp'] = 'application/dfxp';