在Codeigniter中上传svg文件 [英] Uploading svg file in Codeigniter

查看:118
本文介绍了在Codeigniter中上传svg文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Codeigniter中上传svg类型的档案。但我不能做与上传库中内置的codeigniters。我试图这样做通过在congig> mimes.php文件中添加此行

I am trying to upload file with type svg in Codeigniter. But i could not do it with codeigniters built in upload library. I have tried to do it by adding this line in congig > mimes.php file

'svgz' => 'image/svg+xml',
'svg' => 'image/svg+xml',

但仍无解。我收到此错误 -

but still no solution. I am getting this error -

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();

任何人都可以帮助我吗?

Can anyone help me please?

提前感谢

推荐答案

您需要在 $ config ['allowed_types '] ,由 | 分隔,而不是MIME类型。尝试此 -

You need to put a list of allowed file extensions in $config['allowed_types'], separated by |, not MIME type. Try this -

$config['allowed_types'] = 'svg';

这篇关于在Codeigniter中上传svg文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆