Ivan
Ivan

Reputation: 5238

Codeigniter 3 does not upload jpeg image

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 ?

Upvotes: 0

Views: 3604

Answers (2)

Jalo
Jalo

Reputation: 31

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.

Upvotes: 3

Ajay Gokhale
Ajay Gokhale

Reputation: 37

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

Upvotes: -1

Related Questions