數據庫刪除成功但是uploads里的圖片沒刪掉 提示unlink出錯 但是路徑沒問題
? ? $sql="select face from m_user where id".$id;
? ? $row=fetchOne($sql);
? ? $face=$row['face'];
? ? $place="../uploads/".$face;
? ? if(file_exists($place)){
? ? ? ? echo "有圖";
? ? ? ? unlink($place);
? ? }
? ? if(file_exists($place)){
? ? ? ?echo "還有圖";
? ? }
2017-06-16
要先刪除圖片,再刪除內容,你把內容先刪了,就找不到圖片了,也就無法刪除圖片
/**
* 刪除用戶
*/
function delUser($id){
? ?//echo $id;
? ?$sql = "select face from imooc_user where id=".$id;
? ?$row = fetchOne($sql);
? ?$face = $row['face'];
? ?if(file_exists("../uploads/".$face)){
? ? ? ?unlink("../uploads/".$face);
? ?}
? ?//var_dump($face);exit;
? ?if(delete('imooc_user',"id={$id}")){
? ? ? ?$mes ="刪除成功!<br/><a href='listUser.php'>查看用戶列表</a>";
? ?}else{
? ? ? ?$mes="刪除失敗!<br/><a href='listUser.php'>請重新刪除</a>";
? ?}
? ?return $mes;
}