- uni.saveFile(OBJECT)
uni.saveFile(OBJECT)
保存文件到本地。
平台差异说明
| 5+App | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 头条小程序 |
|---|---|---|---|---|---|
| √ | x | √ | √ | √ | √ |
注意:saveFile 会把临时文件移动,因此调用成功后传入的 tempFilePath 将不可用。
OBJECT 参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| tempFilePath | String | 是 | 需要保存的文件的临时路径 |
| success | Function | 否 | 返回文件的保存路径,res = {savedFilePath: '文件的保存路径'} |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success 返回参数说明:
| 参数 | 说明 |
|---|---|
| savedFilePath | 文件的保存路径 |
示例代码:
uni.chooseImage({success: function (res) {var tempFilePaths = res.tempFilePaths;uni.saveFile({tempFilePath: tempFilePaths[0],success: function (res) {var savedFilePath = res.savedFilePath;}});}});
