RadControls for ASP.NET AJAX
If you add a RadProgressManager/RadProgressArea to your Web page or user
control, you can include both FileUpload and the standard
<input type=file> (file input) HTML elements. However, the standard
file inputs are unable to find their files automatically. In order to access the files uploaded using
the above controls you need to use the Request.Files collection:
CopyC#
UploadedFile file = UploadedFile.FromHttpPostedFile(Request.Files[FileUpload1.UniqueID])
CopyVB.NET
Dim file As UploadedFile = UploadedFile.FromHttpPostedFile(Request.Files(FileUpload1.UniqueID))
Caution |
|---|
Although you can use standard file input controls with RadProgressArea,
do not use them with RadUpload controls. Standard file input controls
interfere with the properly functioning of RadUpload.
|
Note |
|---|
RadUpload automatically sets the proper enctype
property of the form to:
enctype="multipart/form-data" which is needed when you upload a file.
The <input type="file"> does not set this property so you need to add it manually.
|
Example
The following example illustrates how to save the files uploaded with standard file inputs:
CopyASPX
<asp:FileUpload ID="FileUpload1" runat="server" />
<input type="file" runat="server" id="FileUpload2" />
<asp:Button runat="server" ID="Button1" Text="Submit" OnClick="Button1_Click" />
CopyC#
UploadedFile file = UploadedFile.FromHttpPostedFile(Request.Files[FileUpload1.UniqueID]);
if (file != null)
{
file.SaveAs(Server.MapPath("~/MyFiles/" + file.GetName()));
}
if (file != null)
{
file.SaveAs(Server.MapPath("~/MyFiles/" + file.GetName()));
}
CopyVB.NET
Dim file As UploadedFile = UploadedFile.FromHttpPostedFile(Request.Files(FileUpload1.UniqueID))
If Not file Is Nothing Then
file.SaveAs(Server.MapPath("~/MyFiles/" + file.GetName()))
End If
file = UploadedFile.FromHttpPostedFile(Request.Files(FileUpload2.UniqueID))
If Not file Is Nothing Then
file.SaveAs(Server.MapPath("~/MyFiles/" + file.GetName()))
End If
See Also