Ajax Async File Upload Control

Async File Upload

Asyncfileupload control is used to Asynchronously upload the file to server properties.

Hasfile :

Used to specify whether or not a file is selected with in the file upload control

FileName :

Returns name of the file selected in fileupload control.

FileBytes :

Returns the content of the selected file in the form of Byte array.

Filecontent : 

Returns an IOstream object by using which you can read data from the selected file or write data to the selected file.

uploaderstyle :

used to specify how the Asynch fileuplad will appear. IT has two options ‘traditional’ & ‘modern’

uploadingBackcolor :

Used to specify the back ground color for file upload while the file is uploadoing.

ErrorBackcolor :

Used to specify the background color for the Asyncfileupload if there is any error in uploading the file.

completebackcolor :

Used to specify the background color for ‘file upload control ’ after uploading the file is completed.

Method:

saveAS() :

Used to save the file selected in the Asynfileupload to the server.

Example

The following example demonstrates how to use the AsyncFileupload.

Add a page to the web site , take a toolkit scriptmanager on the page and then design it as follows with one Async fileuplaod, a button & an image control.

For the Asyncfile upload control set the name as AFUL and write the following code within the button upload click event.

Button click

{

if(AFUL.Hasfile)

{

string path=”~/photos/” + AFUL.fileName;

AFUL.saveAs(Mappath(path));

Image1.Imageurl.path l

}}