Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. public function post_edit()
  2. {
  3.  
  4. $data['title'] = 'My Post';
  5.  
  6.  
  7. $id = $this->input->post('id_post');
  8. $nmfes = $this->input->post('namaFes');
  9. $tempat = $this->input->post('tempat');
  10. $tanggal = $this->input->post('tanggal');
  11. $tanggal2 = $this->input->post('tanggal2');
  12. $uploadImg = $_FILES['image']['name'];
  13.  
  14. if ($uploadImg) {
  15. $config['allowed_types'] = 'jpg|gif|png';
  16. $config['image_library'] = 'gd2';
  17. $config['create_thumb'] = FALSE;
  18. $config['maintain_ratio'] = FALSE;
  19. $config['quality'] = '50%';
  20. $config['overwrite'] = TRUE;
  21. $config['width'] = 600;
  22. $config['height'] = 400;
  23. $config['max_size'] = 2048;
  24. $config['encrypt_name'] = FALSE;
  25. $this->load->library('image_lib', $config);
  26. $this->image_lib->resize();
  27. $config['upload_path'] = './assets/img/posting/';
  28.  
  29. $this->load->library('upload', $config);
  30.  
  31.  
  32. if ($this->upload->do_upload('image')) {
  33. $oldImg = $data['postfes']['image'];
  34. if ($oldImg != 'default.jpeg') {
  35. unlink(FCPATH . 'assets/img/posting/' . $oldImg);
  36. }
  37. $newImg = $this->upload->data('file_name');
  38. $this->db->set('image', $newImg);
  39. } else {
  40. $this->session->set_flashdata('message', '<div class="alert alert-danger" role="alert">' . $this->upload->display_errors() . '</div>');
  41. redirect('user/myPost');
  42. }
  43. }
  44.  
  45. $data = array(
  46.  
  47. 'id_post' => $id,
  48. 'namaFes' => $nmfes,
  49. 'tempat' => $tempat,
  50. 'tanggal' => $tanggal,
  51. 'tanggal2' => $tanggal2
  52.  
  53. );
  54. $where = array(
  55. 'id_post' => $id
  56. );
  57.  
  58. $this->PostModel->update_data($where, $data, 'postfes');
  59. $this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Berhasil di terbitkan</div>');
  60. redirect('user/myPost');
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement