1

Here i am using jQuery-File-Upload to upload files. it is working fine. but here file is uploading when we select file, i need to upload file after clicking on submit button. Please help me how to solve this issue. i am using the following code.

   $('#fileupload').fileupload({


        dataType: 'json',
        url: '/VendorReport/UploadFiles',
        autoUpload: true,
        type: boolen,
        Default:true,
        success: function (msg) {

            alert(msg);

        }
    });


<input id="fileupload" type="file" name="files[]">
<input type="submit" id="btnup" value="Upload" />
2
  • 1
    set autoUpload: false, Commented Jun 6, 2014 at 12:27
  • if i keep autoUpload:false it is not allowing file. i need to allow file in file upload and need to work after clicking on submit button. Commented Jun 6, 2014 at 12:30

1 Answer 1

1

You can stop auto-upload behavior by setting autoUpload: false

$('#fileupload').fileupload({
    dataType: 'json',
    url: '/VendorReport/UploadFiles',
    autoUpload: false,
    type: boolen,
    Default:true,
    success: function (msg) {
        alert(msg);

    }
});

EDIT

To upload file on clicking of button:

HTML

<input id="fileupload" type="file" name="files[]">
<input type="submit" id="btnup" value="Upload" />

jQuery

$(document).ready(function(){
    $("#btnup").click(function(){
         $('#fileupload').fileupload({
            dataType: 'json',
            url: '/VendorReport/UploadFiles',
            autoUpload: false,
            type: boolen,
            Default:true,
            success: function (msg) {
                alert(msg);
            }
        });
    });
});

EDIT

Or refer its documentation to follow official way--> How to start uploads with a button click

$('#fileupload').fileupload({
    dataType: 'json',
    url: '/VendorReport/UploadFiles',
    autoUpload: false,
    type: boolen,
    Default:true,
    success: function (msg) {
        alert(msg);
    }
    add: function (e, data) {
        data.context = $('<button/>').text('Click to Upload')
            .appendTo(document.body)
            .click(function () {
                data.context = $('<p/>').text('Uploading...').replaceAll($(this));
                data.submit();
        });
    }
});
Sign up to request clarification or add additional context in comments.

2 Comments

how to upload file while clicking on submit button..?
sorry bro, In depth i don't know how this control works in asp.net

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.