Advertisement
freddy0512

upload

Nov 10th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. public function do_upload()
  2. {
  3. $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
  4. $this->form_validation->set_rules('judul', 'judul', 'required');
  5. $this->form_validation->set_rules('ket', 'ket', 'required');
  6. $this->form_validation->set_rules('tgl', 'tgl', 'required');
  7. $this->form_validation->set_rules('berlaku', 'berlaku', 'required');
  8.  
  9.  
  10. if ($this->form_validation->run() == FALSE)
  11. {
  12. $header = array(
  13. 'title' =>'Welcome to my Website'
  14. );
  15. $content = array(
  16. 'article' =>'Lorem Ipsum Dolor Sit Amet'
  17. );
  18. $data['data_to_load'] = array($header,$content);
  19. $data['tmp_file']='promo/input';
  20. $this->load->view('index',$data);
  21. }
  22.  
  23. else
  24. {
  25.  
  26. $config['upload_path'] = "./gambar/"; //lokasi folder yang akan digunakan untuk menyimpan file
  27. $config['allowed_types'] = 'gif|jpg|png|JPEG'; //extension yang diperbolehkan untuk diupload
  28. $config['file_name'] = url_title($this->input->post('file_upload'));
  29. $this->upload->initialize($config); //meng set config yang sudah di atur
  30. if( !$this->upload->do_upload('file_upload'))
  31. {
  32. echo $this->upload->display_errors();
  33. }
  34. else{
  35. $data = array(
  36. 'gambar'=>$this->upload->file_name,
  37. 'judul' => $this->input->post('judul'),
  38. 'ket' => $this->input->post('ket'),
  39. 'tgl' => $this->input->post('tgl'),
  40. 'masa_berlaku' => $this->input->post('berlaku'),
  41. );
  42.  
  43. //$this->crud->insert($data,'images');
  44.  
  45. $this->promosi_model->addProduct($data);
  46. redirect('promosi');
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement