Advertisement
freddy0512

controller

Feb 6th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. public function proses_edit()
  2. {
  3. //jika tidak ada poto yang di upload
  4. if (empty($_FILES['foto']['name']))
  5. {
  6.  
  7. $data=array('ket'=>$this->input->post('judul'));
  8.  
  9. $condition['id_wall'] = $this->input->post('id_wall');
  10.  
  11. $this->wallpaper_model->updateProject($data,$condition);
  12.  
  13. redirect ('admin/wallpaper');
  14.  
  15. }
  16. //ada poto yang di upload
  17. else
  18. {
  19.  
  20. $this->form_validation->set_rules('judul', 'Judul', 'required');
  21. if ($this->form_validation->run() == FALSE)
  22. {
  23. $data['errors'] = validation_errors();
  24. $this->load->view("admin/tambah_wallpaper",$data);
  25. }
  26. else
  27. {
  28. $config['upload_path'] = './image/wallpaper';
  29. $config['allowed_types'] = 'gif|jpg|png';
  30. $config['max_size'] = '1000';
  31. $config['max_width'] = '1024';
  32. $config['max_height'] = '768';
  33. $this->upload->initialize($config);
  34. if(!$this->upload->do_upload('foto'))
  35. {
  36. $data['errors'] = $this->upload->display_errors();
  37. $this->load->view('admin/tambah_wallpaper',$data);
  38. }
  39. else
  40. {
  41. $upload = $this->upload->data();
  42. $foto = $upload['file_name'];
  43. $data=array('ket'=>$this->input->post('judul'), 'wall' => $foto); $condition['id_wall'] = $this->input->post('id_wall');
  44.  
  45. //script sampean unlink("image/wallpaper" . $this->input->post('old_image'));
  46.  
  47. $this->wallpaper_model->updateProject($data,$condition);
  48.  
  49. redirect('admin/wallpaper');
  50. }
  51. }
  52.  
  53. }
  54.  
  55. }
  56.  
  57.  
  58.  
  59. //model
  60. function updateProject($data, $condition)
  61. {
  62. $this->db->where($condition);
  63. $this->db->update('tabel_wall', $data);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement