A PHP Error was encountered
Severity: Warning
Code Model Upload
Gagal
|
function update($id, $data) { if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { $this->db->where('id_surat',$id); $this->db->from('mas_surat_keluar'); $query = $this->db->get(); foreach($query->result() as $row) { $file=$row->file; if(file_exists('uploads/'.$file)){unlink('uploads/'.$file);} } $pathnya=realpath(APPPATH.'../uploads'); $config=array( 'allowed_types'=>'jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG|pdf|doc|docx', 'upload_path'=>$pathnya, 'max_size'=>2048, //'file_name' => $no_surat.'.pdf', 'overwrite' => false );
$this->load->library('upload',$config); $this->upload->do_upload(); $image_data=$this->upload->data(); $img_url= $image_data['file_name']; $data['file'] = $img_url; } $this->db->where('id_surat',$id); $this->db->update($this->table,$data);
}
|
Code Model Upload Menggunakan fungsi if ( jiga gambar kosong maka tidak ada data yang
unlink)
Code Model Tambahkan fungsi if.
|
if($file != "")
{ if(file_exists('uploads/'.$file)){unlink('uploads/'.$file);}
}
|
Data kosong dapat di upload, Terimakasih
No comments:
Post a Comment