RadControls for ASP.NET AJAX
To enable RadUpload to automatically save files to a folder, all you must do is set a single property,
giving the directory where the files should be saved. Which property you use depends on whether you are using a virtual path name or a physical path name:
The TargetFolder property specifies the name of an existing virtual path such as "~/UploadedFiles".
This virtual path is internally resolved to a physical path by a call to the Server.MapPath() method.
Using virtual paths can make your application more portable.
The TargetPhysicalFolder property specifies the name of an existing physical path where files should be saved.
Using physical paths is useful for applications that need to upload files to the same location, regardless of how they are deployed.
Note |
|---|
If you set both the TargetFolder and TargetPhysicalFolder properties,
RadUpload uses the TargetPhysicalFolder property.
|
When you enable automatic file saving using the TargetFolder or TargetPhysicalFolder properties,
files are saved to the target folder with their original names from the client computer. Some files may still not be saved to the specified folder:
If you are using the integrated validation, invalid files are not saved to the
target folder. You can, however, still access them using the server-side API.
By default, if a file with the same name as an uploaded file already exists in the target directory, RadUpload
does not overwrite the existing file. There are two approaches you can take to deal with name clashes:
You can allow RadUpload to overwrite existing files in the target directory by setting the
OverwriteExistingFiles property to True.
You can write special code to handle the name clash using the FileExists event.
The following example illustrates how to implement automatic file saving. The uploaded files are saved in the "~/MyFiles" folder,
overwriting any existing files:
CopyASPX
<telerik:radupload id="RadUpload1" runat="server" overwriteexistingfiles="true" targetfolder="~/MyFiles" />
<asp:Button runat="server" ID="Button1" Text="Submit" />
See Also