【发布时间】:2013-03-11 01:08:44
【问题描述】:
我正在尝试在 Codeigniter 中上传 svg 类型的文件。但是我无法使用上传库中内置的 codeigniters 来做到这一点。我试图通过在 congig > mimes.php 文件中添加这一行来做到这一点
'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();
谁能帮帮我?
提前致谢
【问题讨论】:
-
But i could not do it。为什么?什么错误? -
@Bibhas -- 这是错误 ----- 您尝试上传的文件类型不被允许。
-
在问题中指定。另外显示您用于上传的代码。
-
@rafi_ccj 从我从文档中看到的,
allowed_type选项应该是这样的$config['allowed_types'] = 'gif|jpg|png';尝试将svg放在那里。 -
@rafi_ccj 正在查看this answer 的类似问题,前提是您已将 SVG mime 类型正确添加到
mime.php(您似乎已经完成),您需要做的就是通过svg作为允许的类型,而不是 mime 类型本身。
标签: php codeigniter