wx.saveFile(OBJECT)
保存文件到本地。
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
tip
: 本地文件存储的大小限制为 10M