如何通过inet1或webbrowser1的 
Content-Type: multipart/form-data; 方式向网页POST数据 
POST数据分 
application/x-www-form-urlencoded 
和 
Content-Type: multipart/form-data 
两种方式 
application/x-www-form-urlencoded方式本人巳经知道了 
现在我想要知道multipart/form-data方式,有谁能帮我写一个实例吗?
-----------------------------------------------------------------------------------------
 人脑潜能开发音音,下载请来 潜能21网 www.qn21.com

解决方案 »

  1.   

    下面是我的实现方法,不过POST后那个vbCrLf变成了A了,谁帮我改正一下啊,一定加分
    sub command1_click() 
      postDataStr = "" 
        HeadersStr = "Accept: application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/QVOD, application/QVOD, */*" & vbCrLf 
        HeadersStr = HeadersStr & "Accept-Language: zh-cn" & vbCrLf 
        HeadersStr = HeadersStr & "Content-Type: multipart/form-data; boundary=---------------------------7d9257d1bd04ba" 
        HeadersStr = HeadersStr & "Accept-Encoding: gzip, deflate" & vbCrLf 
        HeadersStr = HeadersStr & "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" 
        
    postDataStr = "-----------------------------7d93d8646045e" & vbCrLf 
    postDataStr = postDataStr & "Content-Disposition: form-data; name=""action""" & vbCrLf & vbCrLf 
    postDataStr = postDataStr & "publish/publishAction" & vbCrLf 
    postDataStr = postDataStr & "-----------------------------7d93d8646045e" & vbCrLf 
    postDataStr = postDataStr & "Content-Disposition: form-data; name=""_fma.pu._0.r""" & vbCrLf & vbCrLf 
    postDataStr = postDataStr & "55" & vbCrLf 
    postDataStr = postDataStr & "-----------------------------7d93d8646045e--" 
         Dim aByte() As Byte 
          PackBytes aByte(), URLEncode(postDataStr) 
          WebBrowser1.Navigate "http://sell.taobao.com/auction/publish/publish.htm", 0, "", aByte, HeadersStr 
    END SUBPrivate Sub PackBytes(ByRef ByteArray() As Byte, ByVal PostData As String) 
          Dim iNewBytes As Long, mPostData As String 
          mPostData = PostData 
          iNewBytes = Len(mPostData) - 1  ' Get rid of the null termination 
          If iNewBytes < 0 Then 
          Exit Sub 
          End If 
          ReDim ByteArray(iNewBytes) 
          For i = 0 To iNewBytes 
          ch = Mid(mPostData, i + 1, 1) 
          If ch = Space(1) Then 
              ch = "+" 
          End If 'Debug.Print ch, Asc(ch) 
          ByteArray(i) = Asc(ch) 
          Next 
    End Sub 
    上面代码是我的方法,不过,POST后那个vbCrLf 变为A了 
    它是通过PackBytes将 Space(1)转为 + 号 
    谁能说一下将vbCrLf变为什么 
    --------------------------------------------------------------------------
    人脑潜能开发,潜能开发音乐下载 潜能21网 www.qn21.com
      

  2.   

    Get用Inet,POST用WinSock,我个人觉得Browser非常不稳定
        Post = "-----------------------------7d916725110be4" & vbCrLf
        Post = Post & "Content-Disposition: form-data; name=" & Chr(34) & "file1" & Chr(34) & "; filename=" & Chr(34) & Pic_Path & Chr(34) & vbCrLf
        Post = Post & "Content-Type: image/pjpeg" & vbCrLf
        Post = Post & vbCrLf
        Post = Post & Getfile(Pic_Path) & vbCrLf
        Post = Post & "-----------------------------7d916725110be4--" & vbCrLf
        Post2 = "POST /upload.asp?act=upload HTTP/1.1" & vbCrLf
        Post2 = Post2 & "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/QVOD, application/QVOD, */*" & vbCrLf
        Post2 = Post2 & "Referer: http://" & "localhost" & "/upload.asp" & vbCrLf
        Post2 = Post2 & "Accept-Language: zh-cn" & vbCrLf
        Post2 = Post2 & "Content-Type: multipart/form-data; boundary=---------------------------7d916725110be4" & vbCrLf
        Post2 = Post2 & "Accept-Encoding: gzip, deflate" & vbCrLf
        Post2 = Post2 & "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler 4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) )" & vbCrLf
        Post2 = Post2 & "Host: " & "localhost" & vbCrLf
        Post2 = Post2 & "Content-Length: " & Len(Post) & vbCrLf
        Post2 = Post2 & "Cache-Control: no-cache" & vbCrLf
        Post2 = Post2 & "Cookie: ASPSESSIONIDAASQDTQC=BGPHBANANOPNJPCKOAMMBPJH" & vbCrLf & vbCrLf
        Post2 = Post2 & Post
        MsgBox (Post2)
        Form1.Winsock1.CONNECT "localhost", 80
        'MsgBox (Pic_Path)这是我的POST案例,
      

  3.   

    现在用inet1进行get 或是post 几种方式都知道了,不过我现在编一个程序,只能用webbrowser1控件POST才行,所以没办法
      

  4.   

    我现在编一个程序,只能用webbrowser1控件POST才行,所以没办法----------------------------------------------------------------------------
    人脑潜能开发,潜能开发音乐下载 潜能21网 www.qn21.com 
      

  5.   

    我现在编一个程序,只能用webbrowser1控件POST才行,所以没办法 ---------------------------------------------------------------------------- 
    人脑潜能开发,潜能开发音乐下载 潜能21网][/color [color=#FF0000]www.qn21.com