Derin
Derin

Reputation: 1230

RadAsyncUpload OnClientValidationFailed triggering for no reason

Someone asked this question in Telerik forum.

I have a RadAsyncUpload and the function for OnClientValidationFailed is getting called with a wrong file size error even though the file is well within the size limit.

Markup

<telerik:RadAsyncUpload runat="server" ID="fUploader" PostbackTriggers="btnSendEmail,btnSaveDraft" OnClientValidationFailed="fileUploadValidationFailed"></telerik:RadAsyncUpload>

server side

fUploader.TargetFolder = uploadPath;

fUploader.AllowedFileExtensions = New String() {".jpg", ".png", ".gif", ".jpeg", ".bmp", ".tiff", ".pdf", ".gpx", "*.tcx"}

fUploader.MaxFileSize = 2500000

javascript

function fileUploadValidationFailed(sender, args) {
var fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf('.') + 1, args.get_fileName().length);
if (args.get_fileName().lastIndexOf('.') != -1) {//this checks if the extension is correct
    if (sender.get_allowedFileExtensions().indexOf(fileExtention.toLowerCase()) == -1) {
        alert("File type selected is not allowed.  Valid file types are .jpg, .png, .gif, .jpeg, .bmp, .tiff, .pdf, .gpx, .tcx");
    }
    else {
        alert("File too large.  Max file size 2 MB.");
    }
}
else {
    alert("File type selected is not allowed.  Valid file types are .jpg, .png, .gif, .jpeg, .bmp, .tiff, .pdf, .gpx, .tcx");
}}

web.config

<system.web>
    <httpRuntime maxRequestLength="8192"/>
</system.web>

Upvotes: 0

Views: 878

Answers (1)

Derin
Derin

Reputation: 1230

Answer is telerik:RadAsyncUpload will not support dot(.) and star(*)

See the example: AsyncUpload - File Upload via AJAX

enter image description here

Upvotes: 0

Related Questions