CodeIgniter 2.3无法仅上载PNG文件

时间:2014-06-15 19:21:33

标签: php codeigniter

JPG的工作很好,PNG上传失败。

我不能为我的生活找出原因。

我正在使用CodeIgniter 2.3.2。

MIMES.php

'jpg'   =>  array('image/jpeg', 'image/pjpeg'),
'png'   =>  array('image/png', 'image/x-png'),

型号代码:

  $new_file_name = $this->db->insert_id();
  $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'].'/images/mainimg/';
  $config['file_name'] = $new_file_name;
  $config['allowed_types'] = 'png|gif|jpg|jpeg';
  $this->load->library('upload', $config);
  $this->upload->initialize($config);
  if(! $this->upload->do_upload('Image'))
  {
    echo $config['upload_path'] . $this->upload->file_name;
    $errors = $this->upload->display_errors();
    echo $errors;
    exit(-1);
  }

错误:

/Users/Me/Documents/Project/html/images/mainimg/317.png
The filetype you are attempting to upload is not allowed.

1 个答案:

答案 0 :(得分:-2)

$config['allowed_types'] = 'png|gif|jpg|jpeg|pjpeg|x-png'