求救上传图片:The filetype you are attempting to upload is not allowed
本帖最后由 pc1780 于 2010-9-2 09:16 编辑求救:上传图片时报错:The filetype you are attempting to upload is not allowed
控制器代码
$config['file_name']= date("YmdHis");
$config['upload_path']= $path ;
$config['allowed_types'] = 'gif|jpg|jpeg|jpe|png';
$config['max_size'] = '500';
$this->load->library('upload',$config);
if(!empty($_FILES)){
if(!$this->upload->do_upload('urlnew')){
//echo '错误';
$error = $this->upload->display_errors();
echo $error;
}
else{
$uploaded = $this->upload->data();
$url = $save_path.$uploaded['file_name'];
}
}
mimes.php 代码:
'jpg' => array('image/jpeg', 'image/pjpeg'),
参考 FAQ 置顶帖,修改 mimes.php 文件。 本帖最后由 pc1780 于 2010-9-2 13:34 编辑
回复 2# Hex
改 mimes.php 文件 没用,
这是 里面的代码
'gif' => 'image/gif',
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'png' => array('image/png','image/x-png'),
。。。。如果没用的话你只能改上传类了,因为 CI 的上传类恐怕有不完善的地方。
我一般都是改成使用扩展名验证,而不使用 mimes 把 $config['file_name']= date("YmdHis"); 注释就可以了,我也遇到这个问题,CI乱报错 回复 4# Hex
$config['allowed_types']不写是不是代表不检查类型?还是要怎么办才能让他不验证
本地可以传的 到了redphp上报The filetype you are attempting to upload is not allowed. 真是搞不懂 有没有服务器限制的因素呢?
页:
[1]