我收到以下错误,当我尝试上载:“您尝试上传的文件类型为不允许”笨上传不接受.doc文件
。
这里是我的.doc的mime:
'DOC'=>数组( '应用程序/ msword', '应用程序/文档', '申请/文本', '应用/ vnd.msword' 'application/word','application/winword','application/vnd.ms-word','application/x-msw6','application/x-msword'),试图通过添加更多的哑剧来弥补它。我不知道问题是什么......文件是.doc。请注意,上传pdf的工作!我也在使用一个mac。
这里是我的代码:
$sntError = $this->uploadFile($id,'notes','doc|pdf|docx');
private function uploadFile ($id,$input,$extensions) {
$this->load->library('upload');
$config['allowed_types'] = $extensions;
$config['upload_path'] = './upload/sermon/'. $input;
$config['file_name'] = $input .'-'. $id;
$config['max_size'] = '10000';
$config['overwrite'] = true;
$this->upload->initialize($config);
$uploaded = $this->upload->do_upload($input);
$errors = $this->upload->display_errors('<div class="error">', '</div>');
if (!$errors && $uploaded) {
$fileData = $this->upload->data();
$this->saveSermonAttachments($id,$input,$fileData['file_name']);
} else {
return $errors;
}
}
如果我没有记错,在'数据()'将返回文件的内容,即使载有错误而终止。你能检查数据的内容并查看[file_type]吗? –
谢谢老兄。这帮助我找到了问题。显然文件类型是文本/纯文本。所以我只是将它添加到.doc的已批准MIME中。谢谢。 – Samir