找回密码
 加入
搜索
查看: 572|回复: 2

[网络通信] 如何 post 文件(已解决)

[复制链接]
发表于 2022-8-11 17:55:06 | 显示全部楼层 |阅读模式
本帖最后由 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-TypeTRUEstringmultipart/form-data


3.2. Body

字段名必须数据类型名称和范例
fileTRUEFile文件内容(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://******')


发表于 2022-8-12 11:12:00 | 显示全部楼层
多用搜索
https://www.autoitx.com/forum.ph ... ;tid=55459#lastpost
post的资料还是很多的
 楼主| 发表于 2022-8-12 12:09:38 | 显示全部楼层
风过无痕 发表于 2022-8-12 11:12
多用搜索
https://www.autoitx.com/forum.php?mod=viewthread&tid=55459#lastpost
post的资料还是很多的

金钱都负了,不过已经测试出来
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-25 23:59 , Processed in 0.076101 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表