求教高手:HTTP上传的文件读写原理。。。[
根据我理解过程应该是这样的: 从客户端把二进制文件转换成字符串,然后流到服务器上用ADODB.Stream再转换成二进制文件保存,中间从客户端到服务器的传递过程一直是字符串
这样对么?为什么我在写VB模拟表单上传文件的时候,把文件用二进制读取,然后转换成字符串POST总是没发成功。。。
我的文件读取+字符串转换模块如下
Public Function BinaryToString(ByVal BinaryStr As Variant) As String 'On Error Resume Next Dim lnglen As Long Dim tmpBin As Variant Dim strC As String Dim skipflag As Long Dim i As Long skipflag = 0 strC = "" If Not IsNull(BinaryStr) Then lnglen = LenB(BinaryStr) For i = 1 To lnglen If skipflag = 0 Then tmpBin = MidB(BinaryStr, i, 1) If AscB(tmpBin) > 127 Then strC = strC & Chr(AscW(MidB(BinaryStr, i + 1, 1) & tmpBin)) skipflag = 1 Else strC = strC & Chr(AscB(tmpBin)) End If Else skipflag = 0 End If Next End If BinaryToString = strC End FunctionPublic Function Getfile(FileName As String)Dim DAT() As ByteDim FileSize As Long '文件长度FileSize = FileLen(FileName) '获取文件长度ReDim DAT(FileSize - 1) As ByteOpen FileName For Binary As #1Get #1, , DATCloseGetfile = BinaryToString(DAT)End Function