我想從文件夾改變笨的圖像,取代先前上傳的圖片,並刪除以前的圖片:想改變笨
這裏是我的控制器。但它不工作:
public function changeImage(){
//$user_id = $this->profile_model->changeImage();
/************* File Upload ************/
$config['upload_path'] = './uploads/user_pic/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload',$config);
$filetype = $_FILES['user_pic']['type'];
$file_name = $_FILES['user_pic']['name'];
if($filetype == "image/jpg")
$file_type='jpg';
else if ($filetype == "image/gif")
$file_type='gif';
else if($filetype == "image/jpeg")
$file_type='jpg';
else if($filetype == "image/pjpeg")
$file_type='pjpeg';
else if($filetype == "image/png")
$file_type='png';
$_FILES['user_pic']['name']=$user_id.'.'.$file_type;
$this->upload->do_upload('user_pic');
$up_dtat = array('user_pic' => $_FILES['user_pic']['name']);
$this->db->where('user_id',$user_id);
$this->db->update('tbl_users',$up_dtat);
redirect('profile');
}
不工作...請您在最後的評論我的編輯功能@Nidhi – Sabbir
解釋我發出@Sabbir ...不工作,但在這種情況下?圖像沒有被覆蓋或不刪除? – Nidhi