Help us to translate this website and improve this translation!
English | Castellano

How to Use the FileUpload AJAX Control

Directories and Files

As long as we have write permissions, FileUpload AJAX offers advantages to us beyond the standard FileUpload control, mainly in the way it handles the directories we need to work with.

Two of those characteristics are denoted by these properties:
  • Directory_CreateIfNotExists: if true (it is it by default), it will verify that the directory to store the file exists. If the directory does not exist, it will create it.
  • File_RenameIfAlreadyExists: if true (it is by default), it will verify if a file with the same name already exists in the directory, and, if it does exist, it will rename the file. For example, imagine that in our site we wanted to allow people to post photos of the football player David Villa. It is likely that more than one of the photos is named "DavidVilla.jpg" or other similar names. Using the property File_RenameIfAlreadyExists, the control will rename the file to "DavidVilla_x.jpg", where "x" is a unique number.
In the example we have deactivated File_RenameIfAlreadyExists. When you try to upload a file twice with the same name, it will give an error (unlike the rest of the examples). After you erase the file that you have uploaded, you can verify that you can now upload one with the same name.


<cc1:FileUploaderAJAX ID="FileUploaderAJAX1" runat="server" MaxFiles="5" />
FileUploaderAJAX1.File_RenameIfAlreadyExists = false;