This is a migrated thread and some comments may be shown as answers.

Client-Side programming with RadAsyncUpload

3 Answers 170 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
ELTON
Top achievements
Rank 1
ELTON asked on 12 May 2014, 09:26 AM
May I use client-side api to set  MultipleFileSelection, AllowedFileExtensions, MaxFileSize  ??

3 Answers, 1 is accepted

Sort by
0
Aneliya Petkova
Telerik team
answered on 14 May 2014, 10:32 AM
Hi Elton,

You can change the allowed file extensions of the RadAsyncUpload on the client using set_allowedFileExtensions property:
var upload = $find('RadAsyncUpload1');
upload.set_allowedFileExtensions(".msi,.gif")

RadAsyncUpload has no client-side properties for MultipleFileSelection and MaxFileSize.

Regards,
Aneliya Petkova
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
upasana
Top achievements
Rank 1
answered on 10 Dec 2015, 11:18 AM

Hello Team,

var upload = $find('RadAsyncUpload1');
upload.set_allowedFileExtensions(".msi,.gif")

its not working for me its giving error on setting the extension.

Here is my code:-

function OnClientValidationFailed(sender, args) {
   debugger
        var $row = $(args.get_row());
        var erorMessage = getErrorMessage(sender, args);
        if (erorMessage != undefined) {
            var span = createError(erorMessage);
            $row.addClass("ruError");
            $row.append(span);
        }
      
    }

    function getErrorMessage(sender, args) {
    debugger
        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(fileExtention.indexOf('F')!=0){
                return ("Invalid file type");
            }
        }
        else {
            return ("not correct extension.");
        }
    }

    function createError(erorMessage) {
    debugger
        var input = '<span class="ruErrorMessage">' + erorMessage + ' </span>';
        return input;
    }

  function OnClientFileUploading(sender, args) {
    debugger
        var fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf('.') + 1, args.get_fileName().length);
        var upload =("FileUpload");
        upload.set_allowedFileExtensions("." + fileExtention);
    }

<telerik:RadAsyncUpload ID="FileUpload" runat="server" OnFileUploaded="Upload_FileUploaded"  OnClientValidationFailed="OnClientValidationFailed" OnClientFileUploading="OnClientFileUploading">
</telerik:RadAsyncUpload>

The extension which I want to  set is dynamic like 354647.F01,977543.F08 only "F" will be common in the extension.so i m not able to set it through "AllowedFilesExtensions" property.

And "OnClientValidationFailed" property is not working with setting "AllowedFilesExtensions" property.

so please help me this. or suggest me  if there is any other way to do this.

Please reply ASAP.

0
Ivan Danchev
Telerik team
answered on 15 Dec 2015, 11:14 AM
Hello Upasana,

The js error you are getting is because of the following line in your OnClientFileUploading handler:
var upload =("FileUpload");

It has to be changed as follows, so that the "upload" variable holds a reference to the AsyncUpload object:
var upload = $find("FileUpload");
or
var upload = sender;

Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
AsyncUpload
Asked by
ELTON
Top achievements
Rank 1
Answers by
Aneliya Petkova
Telerik team
upasana
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or