怎样用http把指定的文件夹上传到指定的地址

解决方案 »

  1.   

    那要看你的连接方式了,  也许就是FTP方式呢, 连个更详细的东西也没有叫人怎么给你出主意呀 
      

  2.   

    是用http的方式,我试过用wininet.dll里面的方法,但是总有问题,不知道怎么办,
      

  3.   

    说了半天你还是没有说清楚
    HTTP的方式呢?   是不是类似图片上传呢?
      

  4.   

    我贴段代码,上传的,我不知道哪有问题,请指教
    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