$imgurl = $_FILES['file'];
$pid = $_POST['pid'];
//print_r($imgurl);
if (!empty($imgurl)) {
$uploadme = wp_upload_dir();
if (!function_exists('wp_handle_upload')) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
$upload_overrides = array('test_form' => false);
$movefile = wp_handle_upload($imgurl, $upload_overrides);
print_r($movefile);
嗨,上面是我试图将csv文件上传到wordpress中的数据库的代码。就图像而言,一切都很好但是当我试图上传.csv文件时,我收到了一个错误。
[error] => Sorry, this file type is not permitted for security reasons.
请帮忙。
答案 0 :(得分:0)
将此添加到你的functions.php:
<?php
function cc_mime_types($mimes) {
$mimes['csv'] = 'application/octet-stream';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
?>