codeigniter 3 image upload

Step 1: Load the Upload Library $this->load->library('upload');

Step 2: Set Configuration for File Upload $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $this->upload->initialize($config);

Step 3: Perform the File Upload if ($this->upload->do_upload('userfile')) { // File uploaded successfully $data = $this->upload->data(); } else { // File upload failed $error = array('error' => $this->upload->display_errors()); }