New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Prevent Dual File Uploading

This article shows step by step how to prevent dual uploading of a file which has already been uploaded.

Prevent Dual Files Uploading

  1. Add new RadCloudUpload control.

  2. Handle OnClientFileUploading

ASPNET
<telerik:RadCloudUpload ID="RadCloudUpload1" runat="server" ProviderType="Azure" OnClientFileUploading="onClientFileUploading" MultipleFileSelection="Automatic">
</telerik:RadCloudUpload>
JavaScript
//Prevent uploading of file, which has already been uploaded.
function onClientFileUploading(sender, args) {
	var fileName = args.get_fileName();
	var uploadedFiles = sender.get_uploadedFiles();
	for (var i = 0; i < uploadedFiles.length; i++) {
		if (uploadedFiles[i].originalFileName === fileName) {
			args.set_cancel(true);
			alert(fileName + ' has already been uploaded.');
		}
	}
}

See Also