0

is it possible to cancel AjaxUpload during OnSubmit, for example:

var file_uploader = new window.AjaxUpload(
        'wall-file-upload',
        { action: 'attach_something',
            name: 'userfile',
            onSubmit: function(file,ext) { if(something){cancel_upload();} },        
        }
    );

So cancel upload is executed at onSubmit. Is this possible?

ethereal1m
  • 171
  • 1
  • 3
  • 12

2 Answers2

0

You can use abort() function on jQuery ajax object, but you have to understand, that the request will be processed by the server anyway.

intale
  • 831
  • 5
  • 7
  • abort function must be called by an Ajax object. Can I file_uploader? – ethereal1m Jul 01 '15 at 11:51
  • Well, I need a source of AjaxUpload class to tell you how exactly it must be implemented, if you don't understand how it works – intale Jul 01 '15 at 11:54
  • Hmmm... From the source code. ` // Callback to fire before file is uploaded // You can return false to cancel upload onSubmit: function(file, extension){ } ` So just `return false;` in your onSubmit function and that is all. – intale Jul 01 '15 at 12:06
0

Well in this casze you can try aborting your upload via xhr.abort(), So try

var file_uploader = new window.AjaxUpload(
        'wall-file-upload',
        { action: 'attach_something',
            name: 'userfile',
            onSubmit: function(file,ext) { if(something){xhr.abort();} },        
        }
    );
Dimag Kharab
  • 4,439
  • 1
  • 24
  • 45