CodeIgniter Forums
PNG upload - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: PNG upload (/showthread.php?tid=68263)



PNG upload - Midhun Mohanan P - 06-16-2017

Hi,

Attempting to upload a PNG picture(in the image link) and it is not allowing it to upload. I am able to upload other PNG images.
I can't upload picture in codeigniter forum attachment .

Image link : https://drive.google.com/open?id=0Bz2lajvCzJmDUE51MFNrN1RzWXc

This is my image upload code.

PHP Code:
$config['upload_path'] = FCPATH.'public/images/pins/';
 
$config['allowed_types'] = 'png|gif|jpg|jpeg';

 
$this->load->library('upload'$config);
 if (! 
$this->upload->do_upload("file")) {
 echo 
"invalid";
 
//echo json_encode($FILES['file']['type']);
 
}
 else
 {
 
$image=$this->upload->data();
 
$image_name=$image['file_name'];
 echo 
json_encode($image_name);
 } 



RE: PNG upload - Diederik - 06-17-2017

How do you expect help from the community with so little information? Please provide us with more details, codes and the things you already tried to debug your issue.


RE: PNG upload - Midhun Mohanan P - 06-17-2017

(06-17-2017, 12:05 AM)Diederik Wrote: How do you expect help from the community with so little information? Please provide us with more details, codes and the things you already tried to debug your issue.

Sorry .I have added my code to the topic.


RE: PNG upload - Martin7483 - 06-17-2017

If you can upload other PNG images, then the PNG that is failing might have the PNG extension, but the file mime type does not match that of a PNG image.

CodeIgniter not only checks if a file extension is correct, but it also checks the if the mime type of the file is correct.