1

I've integrated the following piece of code into my CakePHP (Version 1.3): http://sourceforge.net/projects/cakefileupload/

It is working fine and I'm successfully being able to upload files to the server after clicking the upload button. However, I would like the files to be uploaded automatically as soon as I select them.

I added the autoUpload: true option to the jquery.fileupload.js and I changed the add function to the following:

add: function (e, data) {
                if (data.autoUpload || (data.autoUpload !== false &&
                        $(this).fileupload('option', 'autoUpload'))) {
                    data.process().done(function () {
                        data.submit();
                    });
                }
            },

Regardless, I still have to click the upload button in order for the files to go to the server. Any ideas how to enable the automatic upload?

Thank you!

1 Answer 1

1

To enable automatic uploads while selecting files, set the autoUpload option to true

You can use this option while initializing the function in $(document).ready(function(){...

You can see the js file app\webroot\jupload\js\jquery.fileupload-ui.js. The first option is set as false. Make it true.

See the following code:

(function ($) {
'use strict';

// The UI version extends the basic fileupload widget and adds
// a complete user interface based on the given upload/download
// templates.
$.widget('blueimpUI.fileupload', $.blueimp.fileupload, {

    options: {
        // By default, files added to the widget are uploaded as soon
        // as the user clicks on the start buttons. To enable automatic
        // uploads, set the following option to true:
        autoUpload: true, //<----- HERE IS WHAT YOU NEED TO CHANGE
        ..................
        ..................
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! The fix in jquery.fileupload-ui.js did help.

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.