AsyncFileUpload Control

Sloane picture Sloane · Oct 13, 2009 · Viewed 7k times · Source

I am using the new AsyncFileUpload control from the latest AjaxControl ToolKit. My query is regarding the OnClientUploadStarted event which is fired before the upload is started. Is there any way to cancel the upload, as I am checking the fileExtension at this point and would like to cancel the upload so that it does not continue and go on to upload the file. My end result is allow only images to be uploaded. Please advise and thanks for your time.

Answer

Sloane picture Sloane · Oct 14, 2009

Got the answer, all I had to do was override the javascript function with this script(not the best answer, but works), you all could have done faster and cleaner

var orig = AjaxControlToolkit.AsyncFileUpload.prototype.raiseUploadStarted;
AjaxControlToolkit.AsyncFileUpload.prototype.raiseUploadStarted = function(e) {
var evt = this.get_events()._getEvent('uploadStarted');
if (evt) {
    if (evt.length > 1)
        return orig(e);
    else if (evt.length === 1)
        return evt[0](this, e);
    }
}