怎样用http把指定的文件夹上传到指定的地址
解决方案 »
- 同一个网页用IE打开没事,用objMSHTML.createDocumentFromUrl打开就出问题该怎么处理?
- 求助,请教下PE文件资源节加密办法~
- VB中屏蔽右键
- 我就纳闷了????这个winsock的连接问题怎么这么灵异??c/s的 大家帮帮我吧.....
- 怎么用 dependency walker!!我不会看啊!!!请高手赐教!!!
- 谁能给一份简单清楚的用ado连接access数据库,查询出结果的例子。请指点,80分(必给)
- 拜托!!关于数据库。谢!
- 怎样用程序在ACCESS中建一个新表?
- 在VB中如何显示声音VU强度的输出
- chartFx控件在哪儿可以找到?谢!
- 怎么把 String 转换成为 Date 类型?
- 求助怎样把matlab里的specgram()的函数该写成Vb里函数
HTTP的方式呢? 是不是类似图片上传呢?
url是地址,sdata应该是数据吧,shead是标题
Public Function sendData(ByVal sUrl As String, ByVal sData As String, ByVal shead As String) As String
Dim bResult As Boolean
On Error GoTo ErrorHandle
bResult = InitialHttpConnect(sUrl)
If bResult = False Then GoTo ErrorHandle
Dim sBuffer As String
Dim lBufferLength As Long
sBuffer = String$(1024, " ")
lBufferLength = Len(sBuffer)
' iRetVal = HttpSendRequest(m_lHttpRequest, shead, Len(shead), sData, Len(sData))
'
' bResult = CBool(iRetVal)
' If bResult = False Then GoTo ErrorHandle
Dim iRetVal As Integer
iRetVal = HttpAddRequestHeaders(m_lHttpRequest, shead, Len(shead), HTTP_ADDREQ_FLAG_ADD)
bResult = CBool(iRetVal)
If bResult = False Then GoTo ErrorHandle
Dim sSend As String
sSend = sData
Dim BufferIn As INTERNET_BUFFERS
BufferIn.dwStructSize = 40
BufferIn.Next = 0
BufferIn.lpcszHeader = 0
BufferIn.dwHeadersLength = 0
BufferIn.dwHeadersTotal = 0
BufferIn.lpvBuffer = 0
BufferIn.dwBufferLength = 0
BufferIn.dwBufferTotal = Len(sSend)
BufferIn.dwOffsetLow = 0
BufferIn.dwOffsetHigh = 0
iRetVal = HttpSendRequestEx(m_lHttpRequest, BufferIn, 0, 0, 0)
bResult = CBool(iRetVal)
If bResult = False Then GoTo ErrorHandle
Dim iSend As Integer
iSend = 0
Dim iSendLen As Integer
iSendLen = 1024 * 5
'sSend = shead + sData
While Len(sSend) > iSendLen And DlgProcess.bCancel = False
iRetVal = InternetWriteFile(m_lHttpRequest, Left(sSend, iSendLen), iSendLen, VarPtr(iSend))
bResult = CBool(iRetVal)
If bResult = False Then GoTo ErrorHandle
sSend = Right(sSend, Len(sSend) - iSendLen)
iTranSize = iTranSize + iSendLen
setProcessInf
Wend
If DlgProcess.bCancel Then
CloseConnect
bError = False
bRSend = False
Exit Function
End If
iRetVal = InternetWriteFile(m_lHttpRequest, sSend, Len(sSend), VarPtr(iSend))
bResult = CBool(iRetVal)
If bResult = False Then GoTo ErrorHandle
iTranSize = iTranSize + Len(sSend)
setProcessInf
iRetVal = HttpEndRequest(m_lHttpRequest, 0, 0, 0)
bResult = CBool(iRetVal)
If bResult = False Then GoTo ErrorHandle
HttpQueryInfo m_lHttpRequest, HTTP_QUERY_CONTENT_TYPE, ByVal sBuffer, lBufferLength, 0
sBuffer = String$(1024, " ")
HttpQueryInfo m_lHttpRequest, HTTP_QUERY_STATUS_CODE, ByVal sBuffer, lBufferLength, 0
If Val(Left(Trim(sBuffer), 1)) > 3 Then GoTo ErrorHandle
sBuffer = String$(1024, " ")
Dim iLen As Long
iRetVal = InternetReadFile(m_lHttpRequest, sBuffer, 1024, iLen)
bResult = CBool(iRetVal)
If bResult = False Then GoTo ErrorHandle
CloseConnect
Exit Function
ErrorHandle:
Debug.Print Err.Description
Debug.Print Err.HelpContext
Debug.Print Err.LastDllError
Err.Clear
HttpQueryInfo m_lHttpRequest, HTTP_QUERY_STATUS_CODE, ByVal sBuffer, lBufferLength, 0
Debug.Print "HTTP_QUERY_STATUS_CODE = " + sBuffer
sBuffer = String$(1024, " ")
CloseConnect
If bRSend = True Then
bError = False
bRSend = False
sendData sUrl, sData, shead
End If
End Function