I see that there is a way to limit the number of file inputs with the RadAsyncUpload control but what I am trying to do is limit the user to only be able to upload 5 files. Is there a settle that will limit the user to only upload a set number of files?
-Chris
6 Answers, 1 is accepted
You could limit the number of the uploaded files using the MaxFileInputsCount property of the RadAsyncUpload. In your case you should set it to 5.
All the best,
Dimitar Terziev
the Telerik team

Drag and Drop is giving javascript error when "MaxFileInputsCount" property is set.
Below is my design,
<telerik:RadAsyncUpload runat="server" ID="rauUpload"
ChunkSize="1048576" InputSize="60" DropZones="#DropZone1"
MaxFileInputsCount="5" MaxFileSize="2000000000" PostbackTriggers="btnUpload" />
I am afraid that I was unable to replicate the mentioned javscript error, using the provided code-snippet. Could you please specify what exactly is the error and what is the version of our controls that you are currently using?
Regards,
Nencho
Telerik

I am not able to replicate that, but my QA found a different issue.
While upload file count is limited to 5, when using the select button, I am still able to drag unlimited files to upload.
Is there a way to fix this drag/drop limit issue?

Here was my solution:
I added the corresponding parameters, to the upload control:
OnClientFileUploaded="Rad_OnClientFileUploaded"
OnClientFileUploadRemoved="Rad_OnClientFileRemoved"
<
telerik:RadCodeBlock
ID
=
"rad_block"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function Rad_OnClientFileUploaded(sender, e) {
if (sender._uploadedFiles.length > sender._maxFileCount) {
alert('File discarded! Exceeds max file limit of ' + sender._maxFileCount);
sender.deleteFileInputAt(1);
$(sender._element).find('input.ruBrowse').hide();
}
}
function Rad_OnClientFileRemoved(sender, e) {
$(sender._element).find('input.ruBrowse').show();
}
</
script
>
</
telerik:RadCodeBlock
>
I would suggest you try the OnClientFilesSelected event which would prevent the unnecessary upload of files.
Please find attached a sample project implementing the suggested approach. To run the project, the Telerik assemblies for .NET 4.5 should be added to the Bin folder.
function
OnClientFilesSelected(sender, args) {
var
selector = sender.get_renderMode() == 2 ?
'.ruInputs .ruFileLI'
:
'.ruInputs .ruUploadProgress'
;
// render mode 2 is Lightweight
if
(args.get_count() + $telerik.$(selector, sender.get_element()).length > sender.get_maxFileCount()) {
args.set_cancel(
true
);
// alert user that the maxFile limit is exceed
}
}
The additional checks are for the case where a upload is ongoing.
Regards,
Peter Milchev
Progress Telerik