Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
600
Cancelling the fileUploading event handler in the ClientSideEvents.html sample
posted

I am using the igUpload jquery upload sample (2011.2\jQuery\Samples\Samples\igUpload\Display\ClientSideEvents\HTML\ClientSideEvents.html) and have tailored this to cancel the fileUploading event as follows (the only change to the sample code is marked in bold):

fileUploading: function (e, args) {
                                        var message =
                                            "<div class='event-fired'>fileUploading " +
                                                "event fired, with file arguments:" +
                                            "</div>" +
                                            "<div class='event-args'>" +
                                                "File ID: " + args.fileId + "<br />" +
                                                "File Path: " + args.filePath + "<br />" +
                                                "File Status: " + args.fileStatus + "<br />" +
                                                "TotalSize: " + args.totalSize + "<br />" +
                                                "Uploaded Bytes: " + args.uploadedBytes +
                                            "</div>";
                                        showEvent(message);
                    return false;
                },

The documentation (http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0) states that this should cancel the event. However, with this change, I still witness the fileSelected event being fired.

I would expect (and desire) this cancellation to stop uploading the file, reset the progress bar and not to call the fileUploaded event handler.

I suspect this error is not down to usage as cancellation of the fileSelecting event works as expected.

Can you confirm how I attain the behaviour I require?

Parents
  • 1800
    Suggested Answer
    posted

    Hi AlistairWood,

    About firing event fileUploading there is very important note. FileUploading event is fired when the client script has been made request to the server to get status about file upload progress(after the file has started uploading). And when the server responses to the client then it is fired this event. But meanwhile it is possible the file to  be uploaded and then even if you cancel upload it won't have effect. So you should check status(in event arguments) whether file is uploaded. And that's why when the file is uploaded(even if you cancel fileUploading event) fileUploaded event will be fired. This is not an error of fileUploading event.You can try just with huge files to see that you can cancel event and see it is working properly.

    Also fileSelected event is fired before fileUploading event.(you should select file before you upload it).

    Thanks,

    Miro Hristov

Reply Children