Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Files Property

HttpRequest.Files Property

Gets the collection of client-uploaded files (Multipart MIME format).

[Visual Basic]
Public ReadOnly Property Files As HttpFileCollection
[C#]
public HttpFileCollection Files {get;}
[C++]
public: __property HttpFileCollection* get_Files();
[JScript]
public function get Files() : HttpFileCollection;

Property Value

An HttpFileCollection object representing a collection of client-uploaded files.

Remarks

The file collection is populated only when the HTTP request Content-Type is multipart/form-data.

Example

The following example writes out the names of all files in the Files collection.

[Visual Basic] 
Dim loop1 As Integer
 Dim arr1() As String
 Dim Files As HttpFileCollection
 
 Files = Request.Files ' Load File collection into HttpFileCollection variable.
 arr1 = Files.AllKeys ' This will get names of all files into a string array.
 for loop1 = 0 To arr1.GetUpperBound(0)
    Response.Write("File: " & Server.HtmlEncode(arr1(loop1)) & "<br>")
 Next loop1
   

[C#] 
int loop1;
HttpFileCollection Files;
 
Files = Request.Files; // Load File collection into HttpFileCollection variable.
arr1 = Files.AllKeys;  // This will get names of all files into a string array.
for (loop1 = 0; loop1 < arr1.Length; loop1++) 
{
   Response.Write("File: " + Server.HtmlEncode(arr1[loop1]) + "<br>");
}
   

[C++] 
int loop1;
HttpFileCollection* Files;

Files = Request->Files; // Load File collection into HttpFileCollection variable.
arr1 = Files->AllKeys;  // This will get names of all files into a string array.
for (loop1 = 0; loop1 < arr1->Length; loop1++)
{
   Response->Write(String::Format(S"File: {0}<br>", Server->HtmlEncode(arr1[loop1])));
}


[JScript] 
var files : HttpFileCollection = Request.Files  // Load File collection into HttpFileCollection variable.
var arr1 : String[] = files.AllKeys             // This will get names of all files into a string array.
for(var loop1 = 0; loop1 < arr1.Length; loop1++){
  Response.Write("File: " + Server.HtmlEncode(arr1[loop1]) + "<br>")
}
   

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpRequest Class | HttpRequest Members | System.Web Namespace

Show:
© 2015 Microsoft