home *** CD-ROM | disk | FTP | other *** search
/ 202.53.64.216 / 202.53.64.216.tar / 202.53.64.216 / janahitha / Admin / AdsAdminUpload.asp < prev    next >
Text File  |  2004-11-26  |  3KB  |  79 lines

  1. <html>
  2.     <head>
  3.         <meta name="author" content="Gopi Tanguturi">
  4.     </head>
  5. <body>
  6. <%
  7. ' Function to upload the data(Image) byte by byte
  8. Sub BuildUploadRequest(RequestBin)
  9.     'Get the boundary
  10.     PosBeg = 1
  11.     PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
  12.     boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
  13.     boundaryPos = InstrB(1,RequestBin,boundary)
  14.     'Get all data inside the boundaries
  15.     Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
  16.         'Members variable of objects are put in a dictionary object
  17.         Dim UploadControl
  18.         Set UploadControl = CreateObject("Scripting.Dictionary")
  19.         'Get an object name
  20.         Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
  21.         Pos = InstrB(Pos,RequestBin,getByteString("name="))
  22.         PosBeg = Pos+6
  23.         PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
  24.         Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
  25.         PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
  26.         PosBound = InstrB(PosEnd,RequestBin,boundary)
  27.         'Test if object is of file type
  28.         If  PosFile<>0 AND (PosFile<PosBound) Then
  29.             'Get Filename, content-type and content of file
  30.             PosBeg = PosFile + 10
  31.             PosEnd =  InstrB(PosBeg,RequestBin,getByteString(chr(34)))
  32.             FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
  33.             'Add filename to dictionary object
  34.             UploadControl.Add "FileName", FileName
  35.             Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
  36.             PosBeg = Pos+14
  37.             PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
  38.             'Add content-type to dictionary object
  39.             ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
  40.             UploadControl.Add "ContentType",ContentType
  41.             'Get content of object
  42.             PosBeg = PosEnd+4
  43.             PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
  44.             Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
  45.             Else
  46.             'Get content of object
  47.             Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
  48.             PosBeg = Pos+4
  49.             PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
  50.             Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
  51.         End If
  52.         'Add content to dictionary object
  53.     UploadControl.Add "Value" , Value    
  54.         'Add dictionary object to main dictionary
  55.     UploadRequest.Add name, UploadControl    
  56.         'Loop to next object
  57.         BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
  58.     Loop
  59.  
  60. End Sub
  61.  
  62. 'String to byte string conversion
  63. Function getByteString(StringStr)
  64.  For i = 1 to Len(StringStr)
  65.      char = Mid(StringStr,i,1)
  66.     getByteString = getByteString & chrB(AscB(char))
  67.  Next
  68. End Function
  69.  
  70. 'Byte string to string conversion
  71. Function getString(StringBin)
  72.  getString =""
  73.  For intCount = 1 to LenB(StringBin)
  74.     getString = getString & chr(AscB(MidB(StringBin,intCount,1))) 
  75.  Next
  76. End Function
  77. %>
  78. </body>
  79. </html>