wx.saveFile(OBJECT)
Save the file locally.
OBJECT parameter description:
[tr]Parameter type required description[/tr]
tempFilePath | String | is the temporary path of the file that | needs to be saved |
success | Function | No | Return the save path of the file, res = {savedFilePath: 'Save path of the file'} |
Function | No | Callback function for failed interface call | |
Function | No | End of interface call The callback function (executed successfully or failed) |
Sample code:
wx.startRecord({ success: function(res) { var tempFilePath = res.tempFilePath wx.saveFile({ tempFilePath: tempFilePath, success: function(res) { var savedFilePath = res.savedFilePath } }) } }) wx.getSavedFileList(OBJECT)
Get the local saved file list
OBJECT parameter description:[tr]Parameter type required description[/tr]
Function | No | The interface calls the successful callback function. For the return result, see success return parameter description | |
Function | No | Callback function that fails to call the interface | |
Function | No | The callback function at the end of the interface call (will be executed if the call is successful or failed) |
success Return parameter description: [tr]Parameter type description[/tr]
String | Interface call result | |
Object Array | File list |
[tr]Key type description[/tr]
String | Local path of the file | |
Number | The timestamp when the file was saved, from 1970/01/01 08:00 :00 The number of seconds to the current time | |
Number | File size, unit B |
wx.getSavedFileList({ success: function(res) { console.log(res.fileList) } }) wx.getSavedFileInfo(OBJECT)
Copy code
Get file information of local files
OBJECT parameter description:
[tr]Required description of parameter type[/tr]
String | Yes | File path | |
Function | No | The callback function is called successfully by the interface. For the return result, see success return parameter description | |
Function | No | Interface call failed The callback function | |
Function | No | The callback function at the end of the interface call (will be executed if the call is successful or failed) |
[tr]Parameter type description[/tr]
String | Interface call result | |
Number | File size, Unit B | |
Number | The file is saved with a timestamp, from 1970/01/01 08:00:00 to the current time Seconds |
wx.getSavedFileInfo({
filePath: 'wxfile://somefile',
//仅做示例用,非真正的文件路径
success: function(res) {
console.log(res.size) console.log(res.createTime)
}
}) wx.removeSavedFile(OBJECT)
##Delete locally stored files
OBJECT parameter description:
[tr]Parameter type required description[/tr]
is the path of the file | that needs to be deleted | success | |||||||||||||||||
No | Callback function for successful interface call | fail | |||||||||||||||||
No | Callback function for failed interface call | complete | |||||||||||||||||
No | The callback function at the end of the interface call (will be executed if the call is successful or failed) |
filePath | String | 是 | 文件路径,可通过 downFile 获得 |
success | Function | 否 | 接口调用成功的回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码
wx.downloadFile({ url: 'http://example.com/somefile.pdf', success: function (res) { var filePath = res.tempFilePath wx.openDocument({ filePath: filePath, success: function (res) { console.log('打开文档成功') } }) } })
更多微信小程序:文件管理 API说明相关文章请关注PHP中文网!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.