B2C电商
B2B交易系统
智慧门店
分销商城
社区电商
查看更多

提供微商城·微分销·小程序开店需求

5分钟开通你的微信商城店铺!
HiShop > Hi小程序 > 小程序开发 >

微信小程序API文件,wx.saveFile保存文件到本地

2020-12-07 作者:黄先生

wx.saveFile(OBJECT)


保存文件到本地。

微信小程序API文件,wx.saveFile保存文件到本地

OBJECT参数说明:

 

参数 类型 必填 说明
tempFilePath String 需要保存的文件的临时路径
success Function 返回文件的保存路径,res = {savedFilePath: '文件的保存路径'}
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

 

success返回参数说明:

参数 说明
savedFilePath 文件的保存路径

示例代码:

wx.chooseImage({
  success: function(res) {
    var tempFilePath = res.tempFilePath
    wx.saveFile({
      tempFilePath: tempFilePath[0],
      success: function(res) {
        var savedFilePath = res.savedFilePath
      }
    })
  }
})

bug & tip

  1. tip: 本地文件存储的大小限制为 10M

推荐文章

微分销 产品资料 领取开店礼包 免费体验
门店管理 裂变获客 商城开发 免费注册