手册
目录
收藏214
分享
阅读90486
更新时间2022-04-11
将本地资源上传到开发者服务器。如页面通过 wx.chooseImage 等接口获取到一个本地资源的临时文件路径后,可通过此接口将本地资源上传到指定服务器。客户端发起一个HTTPS POST请求,其中 Content-Type 为 multipart/form-data 。
OBJECT参数说明:

示例代码:
wx.chooseImage({
success:function(res){
var tempFilePaths = res.tempFilePaths;
wx.uploadFile({
url: 'http://example.com/upload',
filePath: tempFilePaths[0],
name:"file",
formData:{
"user":"test"
}
})
}
})下载文件资源到本地。客户端直接发起一个HTTP GET请求,把下载到的资源根据 type 进行处理,并返回文件的本地临时路径。
OBJECT参数说明:

示例代码:
wx.downloadFile({
url: 'http://example.com/audio/123',
type: 'audio',
success:function(res){
wx.playVoice({
filePath: res.tempFilePath
})
}
}) 相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.2万人学习
共49课时
77万人学习
共29课时
61.7万人学习
共25课时
39.3万人学习
共43课时
70.9万人学习
共25课时
61.6万人学习
共22课时
23万人学习
共28课时
33.9万人学习
共89课时
125万人学习