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

This Class implements all the properties, constructors and methods of the Uploaded Files.

Definition

Constructors

C#
public AsyncPostedFile(UploadedFile postedFile, string fullPath, long contentLength, bool chunkRequest)
Parameters:postedFileUploadedFilefullPathstringcontentLengthlongchunkRequestbool
C#
public AsyncPostedFile(UploadedFile postedFile, string fullPath, long contentLength)
Parameters:postedFileUploadedFilefullPathstringcontentLengthlong

Properties

Gets the size in bytes of an uploaded file.

C#
public override long ContentLength { get; }
Property Value:

The length of the file.

Overrides: UploadedFile.ContentLength

Example:
cs-api-definition
bool isValid = true;
if (file.ContentLength > MaxFileSize)
{
isValid = false;
}

Gets the MIME content type of a file sent by a client.

C#
public override string ContentType { get; }
Property Value:

The MIME content type of the uploaded file.

Overrides: UploadedFile.ContentType

Example:
cs-api-definition
Dim Loop1 As Integer
Dim MyFileCollection As UploadedFileCollection = RadAsyncUpload1.UploadedFiles
For Loop1 = 0 To MyFileCollection.Count - 1
If MyFileCollection(Loop1).ContentType = "video/mpeg" Then
'...
End If
Next Loop1

Gets the fully-qualified name of the file on the client's computer (for example "C:\MyFiles\Test.txt").

C#
public override string FileName { get; }
Property Value:

A string containing the fully-qualified name of the file on the client's computer.

Overrides: UploadedFile.FileName

Example:
cs-api-definition
UploadedFile MyUploadedFile = RadAsyncUpload1.UploadedFiles[0];
string MyFileName = MyUploadedFile.FileName;
C#
protected override string InputFieldName { get; }

Overrides: UploadedFile.InputFieldName

Gets a Stream object which points to the uploaded file to prepare for reading the contents of the file.

C#
public override Stream InputStream { get; }
Property Value:

A Stream pointing to the file.

Overrides: UploadedFile.InputStream

Methods

Saves the contents of an uploaded file.

C#
public override void SaveAs(string fullName, bool overwrite)
Parameters:fullNamestringoverwritebool

true to allow an existing file to be overwritten; otherwise, false.

Overrides: UploadedFile.SaveAs(string, bool)

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.

Example:
cs-api-definition
Dim Loop1 As Integer
Dim TempFileName As String
Dim ShouldOverwrite As Boolean = True
Dim MyFileCollection As UploadedFileCollection = RadUpload1.UploadedFiles
For Loop1 = 0 To MyFileCollection.Count - 1
' Create a new file name.
TempFileName = "C:\TempFiles\File_" &amp; CStr(Loop1)
' Save the file.
MyFileCollection(Loop1).SaveAs(TempFileName, ShouldOverwrite)
Next Loop1