小程序php文档,微信小程序API 文件

微信小程序API 文件

wx.saveFile(OBJECT)

保存文件到本地。

OBJECT参数说明:

8c27db30249a5a1c7ce4be590ff3bd90.png

示例代码:wx.startRecord({

success: function(res) {

var tempFilePath = res.tempFilePath

wx.saveFile({

tempFilePath: tempFilePath,

success: function(res) {

var savedFilePath = res.savedFilePath

}

})

}

})

bug & tiptip: 本地文件存储的大小限制为 10M

wx.getSavedFileList(OBJECT)

获取本地已保存的文件列表

OBJECT参数说明:

2c710b5f45c277a5e35187a6494bfbb2.png

success返回参数说明:

d3c0cde3e15596999b858f0285ca7a5b.png

fileList中的项目说明:

2a169f324fb624fb613fca27eef99898.png

示例代码:wx.getSavedFileList({

success: function(res) {

console.log(res.fileList)

}

})

wx.getSavedFileInfo(OBJECT)

获取本地文件的文件信息

OBJECT参数说明:

9c1384bbf7c226c0b3d7b139638fd4cf.png

success返回参数说明:

35d1ed5f30de799e4a191484a83ec0b2.png

示例代码:wx.getSavedFileInfo({

filePath: 'wxfile://somefile', //仅做示例用,非真正的文件路径

success: function(res) {

console.log(res.size)

console.log(res.createTime)

}

})

wx.removeSavedFile(OBJECT)

删除本地存储的文件

OBJECT参数说明:

ce323170cacc854214deadaddebaab10.png

示例代码:wx.getSavedFileList({

success: function(res) {

if (res.fileList.length > 0){

wx.removeSavedFile({

filePath: res.fileList[0].filePath,

complete: function(res) {

console.log(res)

}

})

}

}

})

wx.openDocument(OBJECT)

新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx

OBJECT参数说明:参数说明必填说明filePathString是文件路径,可通过 downFile 获得

successFunction否接口调用成功的回调函数

failFunction否接口调用失败的回调函数

completeFunction否接口调用结束的回调函数(调用成功、失败都会执行)

示例代码wx.downloadFile({

url: 'http://example.com/somefile.pdf',

success: function (res) {

var filePath = res.tempFilePath

wx.openDocument({

filePath: filePath,

success: function (res) {

console.log('打开文档成功')

}

})

}

})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值