I am uploading a binary file to a server running ASP. The upload occurs from a web page that has a simple form that has a browse/file upload button on it. The ASP page follows. After reading the binary data into the string, I search for the uploaded file part of the form data and extract it to a string in an attempt to get at the binary data (not shown).
My intention is to process the uploaded binary file and use the data to generate a response that is served back to the browser.
The problem is that the uploaded file data I extract into the string seems to have the bit 8 of each character stripped off. Ive tried various charsets with varying (wrong) results.
I know I can use an existing ASP upload component but I don't need to baggage they have and I was trying to code something leaner.
Did the MSB binary data make it? If I were to save the binary data stream to a file would the MSB's be there? I don't want to save to a file and read it back. I'd rather process the data at this point. How can I access each byte of data in the SafeArray BinaryData? Or perhaps read it byte by byte from the stream?
var InputStream = Server.CreateObject ("ADODB.Stream") ;
InputStream.Type = 1 ;
InputStream.Open () ;
var BinaryData = Request.BinaryRead (Request.TotalBytes) ;
InputStream.Write (BinaryData) ;
InputStream.Position = 0 ;
InputStream.Type = 2 ; // adTypeText=2
InputStream.Charset = "us-ascii" ;
var StringData = InputStream.ReadText () ;
Response.Write ("StringData = ") ;
Response.Write (StringData) ;
Response.Write ("<br><br>") ;