Uploading image with Codeigniter Uploading ignored allowed types and file sizes
I have a code to load a user image, my code is working well, but I am getting a problem when checking allowed_types
ie png|jpg
and max_size
.. It does not check for valid type and max size
code:
$this->load->library('upload');
$config['upload_path'] = 'admin/upload/';
$config['allowed_types'] = 'jpg|jpeg';
$config['max_size'] = '100';
$this->load->library('upload', $config);
$this->upload->initialize($config);
$this->upload->set_allowed_types('*');
if (!$this->upload->do_upload('user_image')){
$data = array('msg' => $this->upload->display_errors());
$flag="1";
}else {
$image_path = $this->upload->data();
$flag="2";
}
Output:
$flag
always set to 2 ... even i downloaded a .png or .gif file and the same problem for max_size
+3
source to share