以下是引用sam_jiang在2022-11-19 23:09:15的发言:
你可以参考这篇文章。。。
https://blog.
我现在已经在前面做好了登录,现在不知道如何加入文件的二进制数据到上传信息中。
YMID1=STREXTRACT(POWINHTTP.RESPONSETEXT, [__VIEWSTATE" value="], [" />])
YMID2=STREXTRACT(POWINHTTP.RESPONSETEXT, [__EVENTVALIDATION" value="], [" />])
&&设定数据分隔
POSTFGF="----WebKitFormBoundarySSoR4BK8bRgIJUh0"
**重新构建POST数据
POSTDATA="--"+POSTFGF+CHR(13)
POSTDATA=POSTDATA+[Content-Disposition: form-data; name="__VIEWSTATE"]+CHR(13)+CHR(13)+ZHURL(YMID1)+CHR(13)
POSTDATA=POSTDATA+"--"+POSTFGF+CHR(13)
POSTDATA=POSTDATA+[Content-Disposition: form-data; name="__EVENTVALIDATION"]+CHR(13)+CHR(13)+ZHURL(YMID2)+CHR(13)
POSTDATA=POSTDATA+"--"+POSTFGF+CHR(13)
POSTDATA=POSTDATA+[Content-Disposition: form-data; name="ctl00$ContentPlaceHolder1$UpFile"; filename="]+[20221119202630ks.xls]+["]+CHR(13)&&文件名
POSTDATA=POSTDATA+[ Content-Type: application/vnd.ms-excel]+CHR(13)
POSTDATA=POSTDATA+FILETOSTR("20221119202630ks.xls")+CHR(13)&&加入文件的二进制数据
POSTDATA=POSTDATA+"--"+POSTFGF+CHR(13)
POSTDATA=POSTDATA+[Content-Disposition: form-data; name="ctl00$ContentPlaceHolder1$UploadBtn"]+CHR(13)+CHR(13)
POSTDATA=POSTDATA+"--"+POSTFGF+CHR(13)
STRTOFILE(POSTDATA,"POSTdata.TXT")
POWINHTTP.OPEN("POST", SURL, .F.)
POWINHTTP.SETREQUESTHEADER("Content-Type", "multipart/form-data; boundary="+POSTFGF)
*!*
POWINHTTP.SETREQUESTHEADER ("Content-Length",LEN(POSTSTR))
POWINHTTP.SETREQUESTHEADER("Referer", SURLR )
POWINHTTP.SEND(POSTSTR)
&& 提交表单进行登录