0

I have problem when i try to upload jpeg image. My configuration is :

$config['allowed_types'] = 'gif|jpg|png|jpeg';

And mimes:

'jpeg'  =>  array('image/jpeg', 'image/pjpeg'),

All other formats like gif, jpg, png work fantastic, only not work when i try to upload jpeg

What can be problem? Anyone have some problem ?

Ivan
  • 5,139
  • 11
  • 53
  • 86

2 Answers2

3

Sometimes the file extension does not tell the truth. Check the real MIME type of the file. Use something like exiftool. For example: You have your_notjpg_file.jpg, but this file's mime is image/webp, then add this MIME Type to the jpg extension in config file: ./application/config/mimes.php.

'jpg'   =>  array('image/jpeg', 'image/pjpeg', 'image/webp'),

Or rename that file before update to the correct extension, and be sure, that this extension is in mimes.php and in your upload config:

$config['allowed_types'] = 'gif|jpg|jpeg|png|webp';

I have had similar problem when I tried to upload some thumbnail images from Youtube. All of them were with jpg extension. As it turned out, jpg was not jpg, but webp. This worked for me.

Jalo
  • 31
  • 1
  • 4
-1

Please try with

$config['allowed_types'] = '*'; //All Types of Images

If it is working then Please check with $_FILES for what mime type your browser read.

Same issue with file upload for .xls. Please check answer:

Unable to import xlsx file in Codeigniter

Community
  • 1
  • 1
  • Please check with $_FILES for mime type which is your browser read and update your mimes.php file which is located in ./application/config/mimes.php – Ajay Gokhale May 10 '16 at 12:31
  • So you are telling cant upload file with virus!! Evan can upload in jpeg format too – Abdulla Nilam May 10 '16 at 12:45
  • I am not telling about virus. Please upload .jpeg file and check mime type using $_FILES. On my end Chrome, FF and Safari .jpeg file return mime type is [type] => image/jpeg – Ajay Gokhale May 11 '16 at 05:51