• 七牛云上传的图片进行删除


    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
     
  • 相关阅读:
    1014. 福尔摩斯的约会
    1009. 说反话
    1002. 写出这个数
    1031. 查验身份证
    1021. 个位数统计
    1006. 换个格式输出整数
    1058. A+B in Hogwarts
    1027. Colors in Mars
    1019. General Palindromic Number
    Windows 新装进阶操作指南
  • 原文地址:https://www.cnblogs.com/lst619247/p/8308884.html
Copyright © 2020-2023  润新知