Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.