Advertisement
Guest User

Update_foto

a guest
Feb 26th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. public function editPgnsiswa()
  3. {
  4.     $id_user    = $this->input->post('id_user', TRUE);
  5.     $nis        = $this->input->post('nis', TRUE);
  6.     $nama       = $this->input->post('nama', TRUE);
  7.     $pwd        = md5($this->input->post('pwd', TRUE));
  8.     $old_image  = $this->input->post('old_image', TRUE);
  9.     $row        = $this->Mpengguna->dtail($id_user)->row();
  10.  
  11.     if(ISSET($_FILES['foto']['name']) && !empty($_FILES['foto']['name'])){
  12.         $config['upload_path']      = 'assets/img/siswa/';
  13.         $config['allowed_types']    = 'gif|png|jpg';
  14.         $config['max_size']         = '100';
  15.         $config['max_widht']        = '1000';
  16.         $config['max_height']       = '1000';
  17.         $config['file_name']        = round(microtime(true)*1000);
  18.         $file_extension             = pathinfo($_FILES["foto"]["name"], PATHINFO_EXTENSION);
  19.  
  20.         $this->load->library('upload', $config);
  21.         if ($this->upload->do_upload('foto'))
  22.         {
  23.             unlink("assets/img/siswa/".$row->foto);
  24.             $foto   = $config['file_name'].".".$file_extension;
  25.         }else{
  26.             $foto   = $row->foto;
  27.         }
  28.  
  29.     }else{
  30.         $foto   = $row->foto;
  31.     }
  32.  
  33.     $data = array(
  34.         'nis'   => $nis,
  35.         'nama'  => $nama,
  36.         'pwd'   => md5($pwd),
  37.         'foto'  => $foto,
  38.     );
  39.    
  40.     $where = array(
  41.         'id_user' => $id_user,
  42.     );
  43.  
  44.     $process = $this->Mpengguna->updatetpgnsiswa($data,$where);
  45.     if ($process) {
  46.         $this->session->set_flashdata('message', 'Berhasil melakukan proses update data');
  47.         redirect('Pengguna/allPengguna');
  48.     }
  49.     else{
  50.         $this->session->set_flashdata('message', 'Gagal melakukan proses update data');
  51.         redirect('Pengguna/allPengguna');
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement