【发布时间】:2016-07-10 14:53:26
【问题描述】:
我正在使用 codeigniter 框架。我想上传 doc 或 docx 文件。所以我写了这样的代码:
$config['upload_path'] = './uploads/resume/';
$config['allowed_types'] = 'docx|doc|DOC|DOCX';
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('resume'))
{
print_r($error = array('error' => $this->upload->display_errors()));
}
else
{
$upload = $this->upload->data();
print_r($upload);exit;
}
在这里,它显示和错误,如不允许您尝试上传的文件类型。并且文件未上传。
我也修改了 mimes.php 文件并添加了
'doc' => array('application/msword', 'application/vnd.ms-office'),
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
当我打印 $this->upload->data() 时,它将 file_type 显示为 application/vnd.oasis.opendocument.text
但是,它不起作用。那么我怎样才能上传 doc 或 docx 文件呢?
【问题讨论】:
-
你的 CI 版本是多少?
-
@Abdulla 它的 2.2.6
-
你加载库了吗??
-
@Abdulla 是的,我有加载库。
标签: php codeigniter