@dedrick
To upload a picture using CodeIgniter, you can follow these steps:
1 2 3 4 |
<form action="your_controller/upload_picture" method="post" enctype="multipart/form-data"> <input type="file" name="userfile"> <input type="submit" value="Upload Picture"> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public function upload_picture(){ $config['upload_path'] = './uploads/'; //set the upload directory $config['allowed_types'] = 'gif|jpg|png'; //set allowed file types $this->load->library('upload', $config); if (!$this->upload->do_upload('userfile')) { $error = array('error' => $this->upload->display_errors()); //handle the error as needed } else { $data = array('upload_data' => $this->upload->data()); //save the file info to the database or display success message } } |