#2
吹水佬2024-04-05 11:01
|
lcDescription="lcDescription"
lcFilePath = GETFILE()
lcFileContent =FILETOSTR(lcFilePath)
lcApiUrl="https://api.
lcApiKey="我的APIKEY"
*// 创建XMLHTTP对象实例
loXmlHttp = CREATEOBJECT("MSXML2.XMLHTTP")
*// 设置请求方法和URL
loXmlHttp.open('POST', m.lcApiUrl, .F.)
*// 构造boundary用于multipart/form-data
lcBoundary ="--"+ALLTRIM(SYS(2))+ALLTRIM(STR(RAND(9999)))
lcContentType = "multipart/form-data; boundary=" + lcBoundary
*// 构造表单数据
lcFormData = '--' + lcBoundary + CHR(13) + CHR(10) + ;
'Content-Disposition: form-data; name="files"; filename="选择的文件.TXT"' + CHR(13) + CHR(10) + ;
'Content-Type: multipart/form-data' + CHR(13) + CHR(10) + CHR(13) + CHR(10) +;
lcFileContent + CHR(13) + CHR(10) +;
'--' + lcBoundary + CHR(13) + CHR(10) + ;
'Content-Disposition: form-data; name="descriptions"' + CHR(13) + CHR(10) + CHR(13) + CHR(10) + ;
lcDescription + CHR(13) + CHR(10) + ;
'--' + lcBoundary + '--' + CHR(13) + CHR(10)
*// 设置请求头
loXmlHttp.setRequestHeader("Content-Type", lcContentType)
loXmlHttp.setRequestHeader("Authorization", "Bearer " + lcApiKey)
*// 发送POST请求
loXmlHttp.send(lcFormData)
[此贴子已经被作者于2024-4-5 01:46编辑过]