Advertisement
yudhaez0212

Untitled

Oct 6th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2.  
  3. public function save()
  4. {
  5. $post = $this->input->post();
  6. $this->ID_COMPLAIN = mt_rand(100000, 999999);
  7. $this->Nama = $post['Nama'];
  8. $this->NPK = $post['NPK'];
  9. $this->Divisi = $post['Divisi'];
  10. $this->Department = $post['Department'];
  11. $this->Nama_Atasan = $post['Nama_Atasan'];
  12. $this->Subject_Abnormality = $post['Subject_Abnormality'];
  13.  
  14. $config['upload_path'] = './assets/gambar/';
  15. $config['allowed_types'] = 'gif|jpg|png';
  16. $config['file_name'] = $this->ID_COMPLAIN;
  17. $config['overwrite'] = true;
  18. $config['max_size'] = 3024;
  19.  
  20. /*
  21. $this->load->library('upload', $config);
  22.  
  23. if ($this->upload->do_upload('images')) {
  24. $this->Attachment = $this->upload->data("file_name");
  25. }else{
  26. $this->Attachment = "default.jpg";
  27. }
  28. */
  29.  
  30. $media = $_FILES;
  31.  
  32. $tmp_name = $media['images']['tmp_name'];
  33. $name = $config['file_name'].'.jpg'; // using config
  34. // $name = $media['images']['name']; // using origin file name
  35.  
  36. $dir_upload = $config['upload_path'];
  37. $uploaded = move_uploaded_file($tmp_name, $dir_upload.$name);
  38. if ($uploaded) {
  39. $this->Attachment = $name;
  40. } else {
  41. $this->Attachment = "default.jpg";
  42. }
  43.  
  44. $this->Keterangan_Abnormality = $post['Keterangan_Abnormality'];
  45. return $this->db->insert($this->_table, $this);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement