當前位置:編程學習大全網 - 編程軟體 - vb6如何實現上傳http站點呢?

vb6如何實現上傳http站點呢?

1.使用socket方式,通過tcp連接web服務器的80端口,發送http協議命令.來實現傳輸.但太底層.都需要自己來實現.不好,

2.使用xmlhttp控件.vb使用他,快速簡單,可以選擇get/post方式

下面是使用的封裝函數.

Function xmlread(url) As String ''用xml讀網頁文件

Set http = CreateObject("Microsoft.XMLHTTP")

http.open "post", url, False

http.setRequestHeader "Content-Type", "text/XML"

http.setRequestHeader "Content-Type", "gb2312"

http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

http.send

If http.readyState = 4 Then

xmlread = Trim(bytes2BSTR(http.responseBody))

Else: xmlread = "error"

End If

Set http = Nothing

End Function

Function xmlpost(url, Form) As String '''用xml傳網頁表單數據

Set http1 = CreateObject("Microsoft.XMLHTTP")

http1.open "post", url, False

http1.setRequestHeader "Content-Type", "text/XML"

http1.setRequestHeader "Content-Type", "gb2312"

http1.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

http1.send Form

If http1.readyState <> 4 Then

xmlpost = "error"

End If

Set http1 = Nothing

End Function

  • 上一篇:請問軟考中級信息安全工程師、網絡工程師、信息系統監理師、信息系統管理工程師等中級職稱哪個容易考試過
  • 下一篇:我想問壹下我電腦的質量!!差了怎麽升級!最好的二手配件!!謝謝大家!
  • copyright 2024編程學習大全網