Parsing multipart/form-data stream

C

Cuong.Tong

Greeting,

Can anyone give me some hints about parsing the mulitpart/form-data
stream?

I have a form looks something like this

<form action="process.dll>
<input type=file name=fileupload> </input>
</form>


So when I choose the local file from the browser, and click submit it
will take me to the process.dll file.

The browser will send a post request to the server with the Headers
looks something like this

-------------Start REQUEST Headers--------------
Content-Length : 28624
Content-Type : multipart/form-data;
boundary=---------------------------3765104465873
Connection : keep-alive
Cookie : SESSION=cPnKc7PmT8wdsy+:ccPnKlJF1Af1d
Host : localhost:9000
Referer : http://localhost:9000/static/template/ajaxupload.html
User-Agent : Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1)
Gecko/20061010 Firefox/2.0
url : /backend/fileupload/test
Accept-Language : en-us,en;q=0.5
Accept-Charset : ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept :
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding : gzip,deflate
Keep-Alive : 300
method : POST
-----------------------------3765104465873
Content-Disposition: form-data; name="filename"; filename="ICE code
review form.doc"
Content-Type: application/msword

Some binary contetn blah blah

-----------------------------3765104465873--



So the question is: what is the best way to parse this stream. I am
particularly insterested in the binary stream under
Content-Type:application/msword

Regard,
 
J

John Timney \(MVP\)

Is there any reason why you cant use asp.net's built in upload tools, which
parse for you?

http://www.codeproject.com/aspnet/fileupload.asp
--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog


Greeting,

Can anyone give me some hints about parsing the mulitpart/form-data
stream?

I have a form looks something like this

<form action="process.dll>
<input type=file name=fileupload> </input>
</form>


So when I choose the local file from the browser, and click submit it
will take me to the process.dll file.

The browser will send a post request to the server with the Headers
looks something like this

-------------Start REQUEST Headers--------------
Content-Length : 28624
Content-Type : multipart/form-data;
boundary=---------------------------3765104465873
Connection : keep-alive
Cookie : SESSION=cPnKc7PmT8wdsy+:ccPnKlJF1Af1d
Host : localhost:9000
Referer : http://localhost:9000/static/template/ajaxupload.html
User-Agent : Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1)
Gecko/20061010 Firefox/2.0
url : /backend/fileupload/test
Accept-Language : en-us,en;q=0.5
Accept-Charset : ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept :
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding : gzip,deflate
Keep-Alive : 300
method : POST
-----------------------------3765104465873
Content-Disposition: form-data; name="filename"; filename="ICE code
review form.doc"
Content-Type: application/msword

Some binary contetn blah blah

-----------------------------3765104465873--



So the question is: what is the best way to parse this stream. I am
particularly insterested in the binary stream under
Content-Type:application/msword

Regard,
 
C

Cuong.Tong

Hi John,

Yes, the reason is that I dont use ASP.NET. I have direct access to the
stream and doesnt have that luxury to get handle on the asp.net
postedfile that is handed over by asp.net.

There's nothing to do with asp.net here as I have my very own webserver
running and have direct access to the data stream posted from client's
browser.

Kind regard,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top