I am trying to upload a .jpeg file using the CI uploader. Doing a migration from C1 2.x to CI 3.0
Code:
$config['upload_path'] = $this->imgUploadFolder;
$config['allowed_types'] = 'gif|jpg|png|JPG|GIF|PNG|jpeg|JPEG';
$config['max_size'] = '1000';
$config['file_name'] = $name;
//Load the upload library
$this->load->library('upload', $config);
//attempt upload
$this->upload->do_upload()) <-- is returing false due to invalid file type
To debug, I dumped the data coming to the upload library
The file type is recognized as image/jpeg
File name is correctly displayed - jamesgregory.jpeg
File extension is correctly displayed as .jpeg
The is_allowed_filetype function in Upload.php returns FALSE.
PHP Code:
public function is_allowed_filetype($ignore_mime = FALSE)
{
if ($this->allowed_types === '*')
{
return TRUE;
}
if (empty($this->allowed_types) OR ! is_array($this->allowed_types))
{
$this->set_error('upload_no_file_types');
return FALSE;
}
$ext = strtolower(ltrim($this->file_ext, '.'));
if ( ! in_array($ext, $this->allowed_types, TRUE))
{
return FALSE;
}
// Images get some additional checks
if (in_array($ext, array('gif', 'jpg', 'jpeg', 'jpe', 'png'), TRUE) && @getimagesize($this->file_temp) === FALSE)
{
return FALSE;
}
if ($ignore_mime === TRUE)
{
return TRUE;
}
if (isset($this->_mimes[$ext]))
{
return is_array($this->_mimes[$ext])
? in_array($this->file_type, $this->_mimes[$ext], TRUE)
: ($this->_mimes[$ext] === $this->file_type);
}
return FALSE;
}
It seems to pass every check and end up at the final return FALSE.
Stumped!