UploadedFile
Provides a way to access individual files that have been uploaded by a client via a RadUpload control.
The UploadedFileCollection class provides access to all files uploaded from a client via single RadUpload instance as a file collection. UploadedFile provides properties and methods to get information on an individual file and to read and save the file. Files are uploaded in MIME multipart/form-data format and are NOT buffered in the server memory if the RadUploadModule is used.
The RadUpload control must be used to select and upload files from a client.
You can specify the maximum allowable upload file size in a machine.config or Web.config configuration file in the maxRequestLength attribute of the <httpRuntime> Element element.
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
public abstract class UploadedFile
Inheritance: objectUploadedFile
Derived Classes:
Inherited Members
Example:
Set the maximum allowable upload file size to 1000kB
<httpRuntime maxRequestLength="1000" />
<httpRuntime maxRequestLength="1000" />
Constructors
protected UploadedFile()
Properties
Gets the size in bytes of an uploaded file.
public abstract long ContentLength { get; }
The length of the file.
Gets the MIME content type of a file sent by a client.
public abstract string ContentType { get; }
The MIME content type of the uploaded file.
Gets the fully-qualified name of the file on the client's computer (for example "C:\MyFiles\Test.txt").
public abstract string FileName { get; }
A string containing the fully-qualified name of the file on the client's computer.
protected abstract string InputFieldName { get; }
Gets a Stream object which points to the uploaded file to prepare for reading the contents of the file.
public abstract Stream InputStream { get; }
A Stream pointing to the file.
Gets the last modified date of the uploaded file.
public DateTime LastModifiedDate { get; }
Last modified date of the uploaded file.
The property is available only in RadAsyncUpload control when FileApi module is used
Methods
Creates a UploadedFile instance from HttpPostedFile instance.
public static UploadedFile FromHttpPostedFile(HttpPostedFile file)
The HttpPostedFile instance. Usually, you could get this from a ASP:FileUpload control's PostedFile property
Returns:Creates a UploadedFile instance from HttpPostedFile instance.
public static UploadedFile FromHttpPostedFile(string inputFieldName, HttpPostedFile file)
The value of the name attribute of the file input field (equals the UniqueID of the FileUpload control)
fileHttpPostedFileThe HttpPostedFile instance. Usually, you could get this from a ASP:FileUpload control's PostedFile property
Returns:Returns the extension of the file on the client's computer.
public string GetExtension()
A string containing the extension of the file including the ".". If the file name does not have extension information, GetExtension returns string.Empty.
The extension of the file name is obtained by searching it for a period (.), starting with the last character and continuing toward the start. If a period is found before a DirectorySeparatorChar or AltDirectorySeparatorChar character, the returned string contains the period and the characters after it; otherwise, string.Empty is returned.
Returns the name and extension of the file on the client's computer.
public string GetName()
A string consisting of the characters after the last directory character in file name on the client's computer.
The separator characters used to determine the start of the file name are DirectorySeparatorChar and AltDirectorySeparatorChar.
Returns the name of the file on the client's computer without the extension.
public string GetNameWithoutExtension()
A string containing the name of the file on the client's computer without the extension.
A string containing the string returned by GetFileName, minus the last period (.) and all characters following it.
Saves the contents of an uploaded file.
public abstract void SaveAs(string fileName, bool overwrite)
The name of the saved file.
overwritebooltrue to allow an existing file to be overwritten; otherwise, false.
The maximum allowed uploaded file size is 4MB by default. Maximum file size can be specified in the machine.config or Web.config configuration files in the maxRequestLength attribute of the <httpRuntime> element.
The ASP.NET process must have proper rights for writing on the folder where the files are saved.
Saves the contents of an uploaded file.
public void SaveAs(string fileName)
The maximum allowed uploaded file size is 4MB by default. Maximum file size can be specified in the machine.config or Web.config configuration files in the maxRequestLength attribute of the <httpRuntime> element.
The ASP.NET process must have proper rights for writing on the folder where the files are saved.