当前位置:网站首页>微信小程序uploadfile服务器,微信小程序之wx.uploadFile[通俗易懂]
微信小程序uploadfile服务器,微信小程序之wx.uploadFile[通俗易懂]
2022-07-06 16:30:00 【Java架构师必看】
大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说微信小程序uploadfile服务器,微信小程序之wx.uploadFile[通俗易懂],希望能够帮助大家进步!!!
wx.uploadFile(Object object)
将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data
url:开发者服务器地址
filePath:要上传文件资源的路径
name:文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容
header:HTTP 请求 Header,Header 中不能设置 Referer
formData:HTTP 请求中其他额外的 form data
success:接口调用成功的回调函数
fail:接口调用失败的回调函数
complete:接口调用结束的回调函数(调用成功、失败都会执行)
实例
wx.chooseImage({
success (res) {
const tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: 'https://example.weixin.qq.com/upload',
filePath: tempFilePaths[0],
name: 'file',
formData: {
'user': 'test'
},
success (res){
const data = res.data
//do something
}
})
}
})
边栏推荐
- Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming
- What should I do if the USB flash disk data is formatted and how can I recover the formatted USB flash disk data?
- The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
- Server SMP, NUMA, MPP system learning notes.
- Scholar doctor hahaha
- Please help xampp to do sqlilab is a black
- Computer reinstallation system teaching, one click fool operation, 80% of people have learned
- 英国都在试行4天工作制了,为什么BAT还对996上瘾?
- [OFDM communication] OFDM system signal detection based on deep learning with matlab code
- pytest多进程/多线程执行测试用例
猜你喜欢

Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming

求帮助xampp做sqlilab是一片黑

AI金榜题名时,MLPerf榜单的份量究竟有多重?

量子时代计算机怎么保证数据安全?美国公布四项备选加密算法

Please help xampp to do sqlilab is a black

If the request URL contains jsessionid, the solution

leetcode:236. 二叉树的最近公共祖先

DAY TWO

The important data in the computer was accidentally deleted by mistake, which can be quickly retrieved by this method

MATLIB从excel表中读取数据并画出函数图像
随机推荐
快手的新生意,还得靠辛巴吆喝?
Today's sleep quality record 78 points
[communication] optimal power allocation in the uplink of two-layer wireless femtocell network with matlab code
How rider uses nuget package offline
Server SMP, NUMA, MPP system learning notes.
How much does the mlperf list weigh when AI is named?
Should the jar package of MySQL CDC be placed in different places in the Flink running mode?
What should I do if the USB flash disk data is formatted and how can I recover the formatted USB flash disk data?
Compile logisim
leetcode:236. The nearest common ancestor of binary tree
【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
DAY TWO
11 preparations for Web3 and Decentralization for traditional enterprises
DAY THREE
MySQL implementation of field segmentation from one line to multiple lines of example code
Yaduo Sangu IPO
(LeetCode)两数之和
Design of short chain
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
Close unregistering application XXX with Eureka with status down after Eureka client starts