我还没有找到一个完美的解决方案,其中使用codeigniter我的访问者可以上传图像的jpeg扩展,我的访问者不会转换任何东西,所以有一个工作,所以我们都可以jpeg扩展,这是当前的代码,给出错误invalid image extension错误。
i'm not uploading whole code to save time and any confusion
$config['upload_path'] = 'upload/path/folder';
$config['allowed_types'] = 'jpeg|jpg|png';
$config['max_size'] = '262144';
$config['file_name'] = 'file_name';
$config['overwrite'] = TRUE;
$this->load->library('upload',$config); 以前我只有$config['allowed_types'] = 'jpg|png
但在接到投诉后,我添加了$config['allowed_types'] = 'jpeg|jpg|png'
但它根本不起作用。
发布于 2021-04-27 06:35:52
这个在codeigniter 3中对我很有效。
N/B:适用于.jfif扩展镜像
打开配置文件mimes.php并添加以下行
'jfif' => array('image/jpeg', 'image/pjpeg'),然后,在您的上传配置中,将此配置用于允许的类型
$config['allowed_types'] = 'gif|jpg|png|JPG|GIF|PNG|jpeg|JPEG|jfif|JFIF';发布于 2015-08-13 18:21:32
虽然没有经过测试,但是你可以尝试一下:
public function do_upload(){
$config = array(
'upload_path' => "./uploads/",
'allowed_types' => "gif|jpg|png|jpeg|pdf|docx",
'overwrite' => TRUE,
'max_size' => "2048000", //File Size
'max_height' => "768",
'max_width' => "1024"
);
$this->load->library('upload', $config);
if($this->upload->do_upload())
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success',$data);
}
else
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('file_view', $error);
}
}https://stackoverflow.com/questions/31985225
复制相似问题