2

I'm using the jQuery fileupload plugin.

I've placed the uploader inside a form (which may not be ideal). The files are uploaded automaticly when added to the queue.

This is the part that handles that:

        // This function is called when a file is added to the queue;
        // either via the browse button, or via drag/drop:
        add: function (e, data) {

            var tpl = $('<li class="working"><input type="text" value="0" data-readOnly="1" /><p></p><i class="icon-remove"></i></li>');

            // Append the file name and file size
            tpl.find('p').text(data.files[0].name)
                .append('<span>' + formatFileSize(data.files[0].size) + '</span>');

            // Add the HTML to the UL element
            $t.find('.auc-upload-list').append(tpl);
            data.context = tpl;

            // Initialize the knob plugin
            tpl.find('input').knob({
                width: 20,
                height: 20
            });

            // Listen for clicks on the cancel icon
            tpl.find('i').click(function(){

                if(tpl.hasClass('working')){
                    jqXHR.abort();
                }

                tpl.fadeOut(function(){
                    tpl.remove();
                });

            });

            // Automatically upload the file once it is added to the queue
            var jqXHR = data.submit();
        },

var jqXHR = data.submit(); initiates the posting.

Unfortunately, all the other form fields are posted aswell. Can I prevent that somehow? So that the fileupload plugin only posts the given file input field?

Or maybe that I tell the plugin which field it can and cannot post?

1 Answer 1

8

Try setting the formData attribute to an empty object. formData contains the additional form data to be sent along with the file upload. The default implementation returns all form fields.

formData : {},

source: https://github.com/blueimp/jQuery-File-Upload/wiki/Options#formdata

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

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.