php - Codeigniter upload unallowed file not producing error -
i running issue using simple codeigniter image upload based on examples in ci documentation.
what going wrong:
1.) if incorrect file type uploaded, not return error. sets of post variables null , continues process.
2.) able upload .sql , (but not all) .exe files, wityh allowed filetypes limited jpg, gif , png.
so, not commonly reported problem of rejecting allowed filetypes, being permissive, , not returning error when should.
$photo = $this->input->post("photo"); $config['upload_path'] = './profile_img/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload', $config); if(isset($_files['userfile']) && $_files['userfile']['size'] > 0){ if ( ! $this->upload->do_upload('userfile')) { $error = $this->upload->display_errors(); $this->session->set_userdata("message", $error); header("location: /page/account"); } else { $upload_data = $this->upload->data(); $photo = $upload_data['file_name']; } } $data = array( 'first_name' => $this->input->post("first_name"), 'last_name' => $this->input->post("last_name"), 'username' => $this->input->post("username"), 'default_meeting_duration' => $this->input->post("default_meeting_duration"), 'notification_type' => $this->input->post("notification_type"), 'photo' => $photo ); $this->user_model->update($data, $this->ion_auth->get_user_id()); $this->session->set_userdata("message", "account settings saved"); header("location: /page/account");
oddly enough, solution in inserting exit() after first redirect within error condition.
apparently, behavior such if error condition found, redirect ignored, , rest of script executed. bug in ci baffling , difficult find.
Comments
Post a Comment