| 发表于:2007-04-20 14:20:18 楼主 |
我用以下代码向163相册上传图片,经抓包,发出的信息没有发送完,只发了一半,请问问题出在哪里? private sub command1_click() me.winsock1.remotehost = "upload.photo.163.com " me.winsock1.remoteport = 80 me.winsock1.connect me.label1 = "connecting... " doevents tmr = timer do until me.winsock1.state = 7 doevents if timer - tmr > = 10 then msgbox "connection timeout. ", vbokonly, "error " me.winsock1.close exit sub end if loop me.label1 = "ready to send... " strhttpheader = strhttpheader & "post /appupload.do?apiname=uploadphoto http/1.1 " & vbcrlf strhttpheader = strhttpheader & "referer: upload.photo.163.com " & vbcrlf strhttpheader = strhttpheader & "accept: text/* " & vbcrlf strhttpheader = strhttpheader & "content-type: multipart/form-data; boundary=---------------------------7d61194b027e " & vbcrlf strhttpheader = strhttpheader & "user-agent: 163upl~1 " & vbcrlf strhttpheader = strhttpheader & "host: upload.photo.163.com " & vbcrlf strhttpheader = strhttpheader & "cookie: ntes_sess=fxnzykyeaeepxdtlufzgdzhiazreedsvzbdejdd1xrelrfayor3ad04hbzal28fe6gy6r2jw0uhyy50l9atbmp5pr; _ntes_nvst=1177017267156, ¦photo ¦ psessionid=ad876049f3f3404a2be7f660dae65e4d.upload-8; netease_ssn=amdlcom; netease_adv=11&23&1177042318041; ntesads2781vichy=photo2782logo:97,17200,0,0,0,0,0,0&photo2782duilianb:2,35,0,nan,0,1,0,0; _ntes_nvid=c15811bbae5405c2dca74a63d1aebd90; _ntes_nnsit= ¦photo ¦research ¦urs ¦stock ¦ _ntes_is_survey=photo; mail163_ssn=amdlcom; theaddr=%u6e56%u5357; ntesads2800lancome=photo2800logob:3,15,0,0,0,0,0,0; hitcounter=amdlcom " & vbcrlf & vbcrlf 'strhttpheader = strhttpheader & "user-agent: mozilla/4.0 (compatible; msie 6.0; windows nt 5.0; .net clr 1.1.4322) " & vbcrlf 'strhttpheader = strhttpheader & "connection: keep-alive " & vbcrlf 'strhttpheader = strhttpheader & "cache-control: no-cache " & vbcrlf strbody = strbody & "---------------------------7d61194b027e " & vbcrlf strbody = strbody & "content-disposition:form-data;name= " "albumid " " " & vbcrlf & vbcrlf 'strbody = strbody & " " & vbcrlf strbody = strbody & "121357160 " & vbcrlf strbody = strbody & "---------------------------7d61194b027e " & vbcrlf strbody = strbody & "content-disposition:form-data;name= " "sid " " " & vbcrlf & vbcrlf ' strbody = strbody & " " & vbcrlf strbody = strbody & "tvrfm056qtbprfuwtxc9pq== " & vbcrlf & vbcrlf strbody = strbody & "---------------------------7d61194b027e " & vbcrlf strbody = strbody & "content-disposition:form-data;name= " "origindim " " " & vbcrlf & vbcrlf 'strbody = strbody & " " & vbcrlf strbody = strbody & "80;80 " & vbcrlf strbody = strbody & "---------------------------7d61194b027e " & vbcrlf strbody = strbody & "content-disposition: form-data; name= " "originfile " ";filename= " " " & me.text1 & " " " " & vbcrlf 'strbody = strbody & "content-type: application/octet-stream " & vbcrlf strbody = strbody & "content-type: image/jpeg " & vbcrlf & vbcrlf 'strbody = strbody & " " & vbcrlf strbody2 = "---------------------------7d61194b027e " & vbcrlf strbody2 = strbody2 & "content-disposition:form-data;name= " "smallerdim " " " & vbcrlf & vbcrlf 'strbody2 = strbody2 & " " & vbcrlf strbody2 = strbody2 & "80;80 " & vbcrlf strbody2 = strbody2 & "---------------------------7d61194b027e " & vbcrlf & vbcrlf strbody2 = strbody2 & "content-disposition: form-data; name= " "smallerfile " ";filename= " "$$_origin_$$ " " & vbcrlf " strbody2 = strbody2 & "content-type: image/jpeg " & vbcrlf & vbcrlf & vbcrlf strbody2 = strbody2 & "---------------------------7d61194b027e-- " & vbcrlf & vbcrlf strhttpheader = strhttpheader & "content-length: " & clng(len(strbody) + len(strbody2) + filelen(me.text1)) & vbcrlf & vbcrlf me.winsock1.senddata strhttpheader & strbody doevents me.label1 = "sending file data... " doevents dim bytbuff(8191) as byte dim bytrem() as byte open me.text1.text for binary as #1 times = int(lof(1) / 8192) redim bytrem(lof(1) mod 8192 - 1) for i = 1 to times get #1, , bytbuff me.winsock1.senddata bytbuff doevents next get #1, , bytrem me.winsock1.senddata bytrem doevents close #1 me.winsock1.senddata vbcrlf & strbody2 doevents me.label1 = "file was sent successfully. " doevents me.winsock1.close end sub |
|
|
|
|