久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網
      最全最豐富的資訊網站

      php刪除圖片的方法實現(xiàn)

      php刪除圖片的方法實現(xiàn)

      php刪除圖片的方法實現(xiàn)

      使用場景:新頭像替換舊的頭像

      步驟:

      1. 讀取數(shù)據(jù)庫頭像的URL地址,

      2. 獲取URL地址的有效字段,

      3. file文件路徑設置

      4. 刪除圖片文件

      Thinkphp 代碼如下:

      public function delPic(){     //獲取前端傳參 用戶的uid     $uid = I('uid');     if(!$uid) $this->error('uid未獲取');     //獲取url     $url = M('Member')->where(array('uid'=>$uid))->getField('avatar');//$url = 'http://www.test.com/up/avatar/59b25bcfcaac6.jpg' if(!$url) $this->error('數(shù)據(jù)庫獲取頭像網址失敗!');     //獲取$url有效字段(去掉網址)     $str = substr($url, 20);//$str = 'up/avatar/59b25bcfcaac6.jpg'     //file文件路徑     $filename = './'.$str;     //刪除     if(file_exists($filename)){         $info ='原頭像刪除成功';         unlink($filename);     }else{         $info ='原頭像沒找到:'.$filename;     }     echo $info; }

      推薦:《PHP教程》

      贊(0)
      分享到: 更多 (0)
      網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號