七牛雲上傳的圖片進行刪除


PHP方法:
/**
 * 七牛雲商品圖片刪除2017/10/25
 */
public function delGoodsImg() {
   $this->isShopLogin();
   $img = I("imgUrl");
   $res = $this->qiNiuDelImg($img);

   if ($res['status'] != 1) {
      //七牛里沒有圖片時,但數據庫里有數據時
      if (!empty($res['err']) && !empty($img)) {
         $gg = M("goods_gallerys");
         $where['goodsImg'] = "http://ang.com/" . $img;
         $imgInfo = $gg->where($where)->find();
         if (!empty($imgInfo)) {
            $res = $gg->where($where)->delete();
         }
      }
      $this->ajaxReturn($res['err']);
   } else {
      $gg = M("goods_gallerys");
      $where['goodsImg'] = "http:/g.com/" . $img;
      $imgInfo = $gg->where($where)->find();
      if (!empty($imgInfo)) {
         $res = $gg->where($where)->delete();
      }

      $this->ajaxReturn("ok");
   }
}

配置刪除路徑 :

var delimg="{:U('Home/Goods/delGoodsImg')}";
//刪除退貨上傳的圖片
        $(document).on("click",".lst1106-SC", function(){
            $(this).parent().remove();
            var imgSrc = $(this).parent().children('img').attr('src');
            var index = imgSrc.lastIndexOf("\/");
            var name = imgSrc.substring(index + 1,imgSrc.length);
        console.log(imgSrc)
        console.log(name)
        $.post(delimg, { imgUrl: name }, function(data) {
               console.log(data);
            });
        });

打印結果:
http://image.jianfengwang.com/o_1c43gn8k15e01ia0tt0898fe9.jpg
 o_1c43gn8k15e01ia0tt0898fe9.jpg
 ok
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM