0

I'm using Jquery File Upload to upload images. Here's my current upload process:

  1. click "Add files" button and browse for files
  2. click the "Start upload" button and files are uploaded

Everything works fine, but I'm trying to skip point n.2 and upload files automatically when just after browsing. Looking inside documentation, I've found this option and setup the following snippet:

// Load existing files:
$.ajax({
    // Uncomment the following to send cross-domain cookies:
    //xhrFields: {withCredentials: true},
    url: $('#fileupload').fileupload('option', 'url'),
    dataType: 'json',
    context: $('#fileupload')[0],
    autoUpload: true
}).done(function (result) {
    $(this).fileupload('option', 'done')
        .call(this, null, {result: result});
});

Unfortunately, nothing happens after file browsing and I still have to press "Start upload" button to begin upload process. What am I missing?

2
  • 1
    Try checking any jquery error by using Inspect Element in Google Chrome and Mozilla. May be it is not working just because of an error. Commented Nov 21, 2014 at 18:16
  • @anujpradhan unfortunately no errors, but nice suggestion anyway. Commented Nov 21, 2014 at 18:19

2 Answers 2

1

Find it out! Since I'm using "jquery.fileupload-ui.js" script, it's sufficient to set (line 51):

autoUpload: true

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

0

You have to set the "autoUploade:true" like this

$('#fileupload').fileupload('option', {
        url : '<your upload url>',
        maxFileSize : 20971520,
        autoUpload: true,
        acceptFileTypes : /(\.|\/)(pdf|doc|jpg|xls|tiff|png)$/i
});

Comments

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.