本帖最后由 fybang 于 2024-8-14 12:37 编辑
一直在使用鱼刺http这个类库,代码层次比较好,可以一步一步的调试,其他类库也有类似代码,大部分都一行代码解决,有问题很难看出在哪里。
但是这个类库上传文件一直很难使用,需要了解很多http细节。
看到论坛上有很多反应这个问题,我自己正好用到上传所以改了一下,希望大家喜欢。
金币紧张欢迎打赏
全部代码下载附件
变量名 | 类 型 | 静态 | 数组 | 备 注 | Param | 上传参数Bin | | | success | 逻辑型 | | | http | WinHttpW | | | boundary | 文本型 | | | response | 文本型 | | | url | 文本型 | | | file | 文本型 | | |
url = “https://www.xxx.com”file = “D:\xxx.png”Param. Add (“media”, 读入文件 (file ), “image/*”, “test.png”)http. Rest ()http. Auto (真)boundary = 取重复文本 (10, “-”) + 文本_取随机字符数字串 (16 )success = http. Open ( #POST, url ) success = 选择 (success, http. SetContentType (“multipart/form-data; boundary=” + boundary ), 假)success = 选择 (success, http. SendBin (Param. ToQuery (boundary, 10 )), 假) 如果真 (success ) response = http. GetResponseTextU2A () 返回 (真)返回 (假)
|