我想问一下codeigniter上传 .
Codeigniter版本2.1.4
我无法将图像上传到在线文件夹,但它在 localhost
上完美运行 .
我上传图片的代码
$config['upload_path'] = './assets/frontend/images/banner/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$this->upload->initialize($config);
$this->upload->do_upload('BannerImg');
$banimg = $this->upload->data();
$bantitle = $this->input->post('BannerTitle');
$bandesc = $this->input->post('BannerDesc');
$this->banner_model->addBanner($banimg,$bantitle,$bandesc);
你知道这是什么问题吗?
已经尝试搜索但无法找到解决方案 .
如果有人可以帮助我,请
谢谢 .
1 回答
由于我们在评论中发现了问题,我将在此处作为参考发布 . 基本上问题在于codeigniter中的
upload_class
,它似乎涉及一些mime类型 . 看到类似的问题:CodeIgniter: "The filetype you are attempting to upload is not allowed."
CodeIgniter "The filetype you are attempting to upload is not allowed."(与1不同)
从上述第1点引用接受的答案:
你使用的是Firefox,不是吗?
您可以尝试查看
system/libraries/Upload.php
第199行:将该行更改为:
然后上传您的
.wmv
文件 . 它会显示像application/octet-stream
之类的东西 . 将其添加到mimes.php
. 希望这个帮助=)同类的回答here
Note: 在您的情况下,它可能不会完全相同但问题类似,您应该找到答案中的相关文件类型并将它们添加到
mimes.php
文件以解决此问题 .一些链接:
CodeIgniter forum's thread
Mimetype corruption in Firefox
Getting around IE’s MIME type mangling