help me understand the following javascript relate to AsyncFileUpload control

Posted by sean717 on Stack Overflow See other posts from Stack Overflow or by sean717
Published on 2010-05-26T21:46:33Z Indexed on 2010/05/26 21:51 UTC
Read the original article Hit count: 713

Filed under:
|

Hi, in my current project I used a AsyncFileUpload control from AJAX Control Toolkits. After I got the async file upload part working, I needed to filter the file type so users can only upload image files. I found the following code off web and it worked well:

function uploadStarted(sender, args) {  
        var filename = args.get_fileName();  
        var filext = filename.substring(filename.lastIndexOf(".") + 1);  
        if (filext == "jpg" || filext == "jpeg" || filext == "gif" || filext == "bmp")      {
            return true;
        }
        else 
        {  
            // force uploading cancel  
            args.set_cancel(true);  
            // set reason of cancel  
            args.set_errorMessage("Invalid File Format Selected");  
            return false;  
        }  
    } 

The problem is : I don't understand this javascript. What is the type of args parameter? Where are the methods such as "get_fileName()", "set_cancel()" defined? I went to the homepage of the AsyncFileUpload control but couldn't find any documentation regarding the "args".

Can someone help me out explaining this Javascript? Thanks

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asyncfileupload