Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function save()
- {
- $post = $this->input->post();
- $this->ID_COMPLAIN = mt_rand(100000, 999999);
- $this->Nama = $post['Nama'];
- $this->NPK = $post['NPK'];
- $this->Divisi = $post['Divisi'];
- $this->Department = $post['Department'];
- $this->Nama_Atasan = $post['Nama_Atasan'];
- $this->Subject_Abnormality = $post['Subject_Abnormality'];
- $config['upload_path'] = './assets/gambar/';
- $config['allowed_types'] = 'gif|jpg|png';
- $config['file_name'] = $this->ID_COMPLAIN;
- $config['overwrite'] = true;
- $config['max_size'] = 3024;
- /*
- $this->load->library('upload', $config);
- if ($this->upload->do_upload('images')) {
- $this->Attachment = $this->upload->data("file_name");
- }else{
- $this->Attachment = "default.jpg";
- }
- */
- $media = $_FILES;
- $tmp_name = $media['images']['tmp_name'];
- $name = $config['file_name'].'.jpg'; // using config
- // $name = $media['images']['name']; // using origin file name
- $dir_upload = $config['upload_path'];
- $uploaded = move_uploaded_file($tmp_name, $dir_upload.$name);
- if ($uploaded) {
- $this->Attachment = $name;
- } else {
- $this->Attachment = "default.jpg";
- }
- $this->Keterangan_Abnormality = $post['Keterangan_Abnormality'];
- return $this->db->insert($this->_table, $this);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement