1

I'm using Jquery file upload by blueimp want to catch an action that happens after upload of file. So, this works fine

.on('change','input[type=file]',function(e)
{
    console.log('OOOOOOOOk');
})

But it's not working for me, because I need action after file upload completed. So, in docs I've found this solution:

var url = './fileUpload/jQuery-File-Upload/server/php/';
      $('#fileupload').fileupload({
          url: url,
          dataType: 'json',
          done: function (e, data) {
              $.each(data.result.files, function (index, file) {
                  $('<p/>').text(file.name).appendTo('#files');
              });
          },
          progressall: function (e, data) {
              var progress = parseInt(data.loaded / data.total * 100, 10);
              $('#progress .progress-bar').css(
                  'width',
                  progress + '%'
              );
          }
      }).prop('disabled', !$.support.fileInput)
          .parent().addClass($.support.fileInput ? undefined : 'disabled')
          .bind('fileuploadcompleted',function(e,data)
            {
              console.log('eventFinished');
            });

But I dont see eventFinished string in console after uploading, but see OOOOOOOk. How can I catch this event then?

1 Answer 1

3

You are binding the 'fileuploadcompleted' event to the parent of actual element, so try re-arranging the code in this way.

var url = './fileUpload/jQuery-File-Upload/server/php/';
  $('#fileupload').fileupload({
      url: url,
      dataType: 'json',
      done: function (e, data) {
          $.each(data.result.files, function (index, file) {
              $('<p/>').text(file.name).appendTo('#files');
          });
      },
      progressall: function (e, data) {
          var progress = parseInt(data.loaded / data.total * 100, 10);
          $('#progress .progress-bar').css(
              'width',
              progress + '%'
          );
      }
  }).bind('fileuploadcompleted',function(e,data)
        {
          console.log('eventFinished');
        }).prop('disabled', !$.support.fileInput)
      .parent().addClass($.support.fileInput ? undefined : 'disabled');
Sign up to request clarification or add additional context in comments.

1 Comment

are you using the UI version of Jquery file upload by blueimp ? if not, then use this event instead 'fileuploaddone'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.