|
本帖最后由 c123456789qs 于 2022-8-12 12:14 编辑
图片文件上传
1.接口地址(post)
url:/upload/File
2.出参范例
{ "status":"done", "url":"https://xx/xx-xx_xx.jpg", "name":"xx .jpg" }
3. 入参介绍
3.1. Header
字段名 | 必须 | 数据类型 | 名称和范例 | Content-Type | TRUE | string | multipart/form-data |
3.2. Body
字段名 | 必须 | 数据类型 | 名称和范例 | file | TRUE | File | 文件内容(png 或 jpg) xx 图片.png |
Func http_file_post($r_send,$r_url)
$oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Option(4) = 13056
$oHTTP.Open("post",$r_url, False)
$oHTTP.SetRequestHeader("Content-Type", "multipart/form-data; boundary=--------------------------851689979019327099708141")
$oHTTP.Send($r_send)
$oHTTP.WaitForResponse()
$ret = BinaryToString($oHTTP.ResponseBody, 4)
MsgBox(0,"",$ret)
EndFunc
根据抓 postman 的包,测试出来了
$text= StringToBinary('----------------------------851689979019327099708141'&@CRLF & _
'Content-Disposition: form-data; name="file"; filename="11.jpg"'&@CRLF & _
'Content-Type: image/jpeg'&@CRLF&@CRLF ,4)
$file=FileOpen("d:\11.jpg",16 )
$text&=FileRead($file)
FileClose($file)
$text&=StringToBinary(@CRLF &'----------------------------851689979019327099708141--'&@CRLF&@CRLF,4)
http_file_post($text,'https://******')
|
|