微信小程序> 微信小程序保存图片到本地

微信小程序保存图片到本地

浏览量:2903 时间: 来源:juan_taylor

转载:打开链接

 wx.getImageInfo({            src: 'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white_fe6da1ec.png',            success: function (ret) {                var path = ret.path;                wx.saveImageToPhotosAlbum({                    filePath: path,                    success(result) {                        console.log(result)                    }                })            }        })

 

 保存之前先download一下, 把返回的tempFilePath临时文件路径给wx.saveImageToPhotosAlbum的filePath参数wx.downloadFile({  url: 'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white_fe6da1ec.png',  success: function (res) {    wx.saveImageToPhotosAlbum({      filePath: res.tempFilePath,      success(result) {        console.log(result)      }    })    wx.saveFile({      tempFilePath: res.tempFilePath,      success: function (res) {        console.log(res.savedFilePath)       }    })      }})

 

wx.getImageInfo({  src: '../images/shareimg.jpg',  success: function (res) {    console.log(res.path)    wx.getSetting({      success(res) {        if (!res.authSetting['scope.writePhotosAlbum']) {          wx.authorize({            scope: 'scope.writePhotosAlbum',            success() {              wx.saveImageToPhotosAlbum({                filePath: res.path,                success(result) {                  console.log(result)                }              })            }          })        }      }    })  }})

 

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎