New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

RadUpload Context

RadUpload has been replaced by RadAsyncUpload, Telerik’s next-generation ASP.NET upload component. If you are considering Telerik’s Upload control for new development, check out the documentation of RadAsyncUpload or the control’s product page. If you are already using RadUpload in your projects, you may be interested in reading how easy the transition to RadAsyncUpload is and how you can benefit from it in this blog post. The official support for RadUpload has been discontinued in June 2013 (Q2’13), although it is still be available in the suite. We deeply believe that RadAsyncUpload can better serve your upload needs and we kindly ask you to transition to it to make sure you take advantage of its support and the new features we constantly add to it.

You can access all uploaded files within the current request using the RadUploadContext object. This is especially useful when you are using standard file input controls. You can obtain an instance of the upload context object using the static(C#) or shared (VB) property Current:


using Telerik.Web.UI...
protected void Button1_Click(object sender, EventArgs e)
{  
    RadUploadContext uploadContext = RadUploadContext.Current;  
    ...
}


Imports Telerik.Web.UI
...
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim uploadContext As RadUploadContext = RadUploadContext.Current
End Sub

The RadUploadContext object has a single property: UploadedFiles. UploadedFiles is a collection of all files that have been uploaded within the current request, including those selected with RadUpload controls and those selected with regular <input type=file> elements.

Each file in the collection is of type UploadedFile. The following table lists the members of the UploadedFile class:

 

Property or Method Type (Return Type) Description
Properties
ContentLength integer The size of the uploaded file, in bytes.
ContentType string The MIME type of the uploaded file.
FileName string The fully qualified name of the file on the client. (IE6 and some older browsers only).To get a file name that is the same for all browsers, use the GetName() method instead.
InputStream System.IO.Stream A stream object that can be used to read the file contents.
Methods
GetName() string Returns the name of the uploaded file.
GetNameWithoutExtension() string Returns the name of the uploaded file, without the file extension.
GetExtension() string Returns the extension of the uploaded file, including the leading dot (".")
SaveAs(string, [bool]) none Save the file to the location specified by the first parameter. The optional second parameter specifies whether to overwrite an existing file if it is found.
GetFieldValue(string) string Retrieves a custom field added to the uploaded file.
GetIsFieldChecked(string) boolean Retrieves whether a custom check box added to the uploaded file was checked.

For an example of using the UploadedFile object, see Manipulating Uploaded Files.

In this article