Reputation: 590
I have below code to upload user image, my code work good but I'm getting issue while checking allowed_types
i.e. png|jpg
and max_size
..
It doesn't check allowed 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 uploaded file .png or .gif and same problem for max_size
Upvotes: 3
Views: 2835
Reputation: 367
Try increasing the max_size. Also remove the line $this->upload->set_allowed_types('*');
Upvotes: 3