anjhar

upload_control

Mar 10th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public function do_upload(){
  2. $config['upload_path'] = $base_url('upload'); //lokasi folder yang akan digunakan untuk menyimpan file
  3. $config['allowed_types'] = 'gif|jpg|png|JPEG'; //extension yang diperbolehkan untuk diupload
  4. $config['file_name'] = url_title($this->input->post('file_upload'));
  5.  
  6. $this->upload->initialize($config); //meng set config yang sudah di atur
  7. //$this->load->library('upload',$config);
  8. //$now = date('Y-m-d h:i:s');
  9. //$id = $this->session->userdata('id');
  10. if(!$this->upload->do_upload('file_upload')){
  11. echo $this->upload->display_errors();
  12. }else{
  13. $data = array(
  14. 'logo'=>$this->upload->file_name
  15. //'tanggal_update'=>$now,
  16. //'id'=>$id
  17. );
  18. $this->crud->insert($data,'home');
  19. redirect('admin/home');
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment