当前位置:网站首页>Wechat applet UploadFile server, wechat applet wx Uploadfile[easy to understand]

Wechat applet UploadFile server, wechat applet wx Uploadfile[easy to understand]

2022-07-06 23:57:00 Java architects must see

Hello everyone , I'm wang Jun , An architect who can write code and recite poetry . Today, let's talk about wechat apps uploadfile The server , Wechat applet wx.uploadFile[ Easy to understand ], I hope it can help you make progress !!!

wx.uploadFile(Object object)

Upload local resources to the server . The client initiates a HTTPS POST request , among content-type by multipart/form-data

url: Developer server address

filePath: Path to upload file resource

name: File corresponding key, Developers can use this on the server side key Get the binary content of the file

header:HTTP request Header,Header Cannot set Referer

formData:HTTP Other extras in the request form data

success: Interface calls the successful callback function

fail: Interface call failed callback function

complete: The callback function at the end of the interface call ( Successful call 、 Failure will be carried out )

example

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

}

})

}

})

原网站

版权声明
本文为[Java architects must see]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061628470026.html