In my current project, I used the AsyncFileUpload control from the AJAX Control Toolkits. After I downloaded the download part of the asynchronous file, I had to filter the file type so that users could only upload image files. I found the following code offline, 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
{
args.set_cancel(true);
args.set_errorMessage("Invalid File Format Selected");
return false;
}
}
The problem is that I do not understand this javascript. What is the type of args parameter? Where are methods such as "get_fileName ()", "set_cancel ()"? I went to the main page of the AsyncFileUpload control, but could not find the documentation regarding "args".
Can someone help me explain this Javascript? Thanks