在Codeigniter中上传svg文件
问题描述:
我想在Codeigniter中上传类型为svg的文件。但是我无法用上传库中的codeigniters来完成它。我曾尝试加入这一行做到在congig> mimes.php文件在Codeigniter中上传svg文件
'svgz' => 'image/svg+xml',
'svg' => 'image/svg+xml',
,但仍然没有解决。我得到这个错误 -
The filetype you are attempting to upload is not allowed.
这里是我的代码
$dir = 'uploads/svg/';
$this->load->library('upload');
$config['file_name'] = $result . '.svg';
$config['upload_path'] = $dir;
$config['allowed_types'] = 'image/svg+xml';
$this->load->library('upload');
$this->upload->initialize($config);
$this->upload->do_upload();
谁能帮助我吗?
在此先感谢
答
你需要把$config['allowed_types']
允许的文件扩展名的列表,由|
,没有MIME类型分开。试试这个 -
$config['allowed_types'] = 'svg';
答
$config['allowed_types'] = 'image/svg+xml';
这应该是:
$config['allowed_types'] = 'svg';
'但我做不到'。为什么?什么错误? – 2013-03-21 13:31:24
@Bibhas - 这是错误-----不允许你正在尝试上传的文件类型。 – rafi 2013-03-21 13:32:57
在问题中指定。另外显示你用来上传的代码。 – 2013-03-21 13:34:34