Uploads property returns reference to WebRequestUploads
object - responsible for parsing user's Request and
access parts of the request if request contained
multipart/form-data content type. If client did not sent
request of such type, this property will still return valid
reference, but Uploads.Count
will be 0.
This property is actually very convinient for accessing
files uploaded by client. For example, you can do this:
User.Request.Uploads(0).Save "c:\somepath\somewhere"
or, you can check out headers that describe specific
part, like this:
User.Request.Uploads(0).Headers.ToString()
which will give you much more information about uploaded
content.
For your reference, typical form-upload content looks
like this:
POST /upload.htm HTTP/1.1
Content-Type: multipart/form-data;
boundary=---------------------------7d42bf19d0826
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)
Host: localhost
Content-Length: 122621
-----------------------------7d42bf19d0826
Content-Disposition: form-data;
name="TheFile"; filename="access.c"
Content-Type: text/plain
#include "access.h"
#include "message.h"
#include "tags.h"
#include "attrs.h"
#include "tmbstr.h"
..rest of the file comes here...
-----------------------------7d42bf19d0826
Content-Disposition: form-data;
name="Name"
this is some data
-----------------------------7d42bf19d0826
Content-Disposition: form-data;
name="Submit"
Submit
-----------------------------7d42bf19d0826--
in this specific case, there will be 3 parts returned
with Uploads property. We colored with blue headers for
each part (accessible through Uploads(xyz).Headers
) and each body with green color (accessible through
Uploads(xyz).Body
or Uploads(xyz).Save
)
Just for the reference, you can copy/paste this HTML
code to see how does web page look like when data is to be
uploaded on the server:
<HTML><BODY>
<FORM action="upload.htm" method=post
encType="multipart/form-data">
<INPUT type=file size=75
name=TheFile> <BR>
<INPUT size=53 value="Enter your name
here...." name=Name>
<INPUT type=submit value=Submit
name=Submit></FORM>
</BODY></HTML>