0

here is my upload function

function ajaxFileUpload() {

    $("#loading")
        .ajaxStart(function () {
        $(this).html('loading...');
        $('#buttonUpload').hide();
    })
        .ajaxComplete(function () {
        $(this).hide();
        $('#buttonUpload').show();
    });

    $.ajaxFileUpload({
        url: '_card_upload.php',
        secureuri: false,
        fileElementId: 'fileToUpload',
        dataType: 'json',
        success: function (data, status) {
            alert(data);
        },
        error: function (data, status, e) {
            alert(e);
        }
    });

    return false;

}    

above function allow user to upload one file to my server, but I need user to specific that this image is public image or not? by add some checkbox

<input type="checkbox" id="public_card" name="public_card" align="absmiddle" />

in upload form

the problem is i dont know how to send a value in checkbox to url:'_card_upload.php' at the same time.

how do i send it?

0

1 Answer 1

1

Try adding data parameter to the ajaxFileUpload call:

$.ajaxFileUpload({
    url: '_card_upload.php',
    data: {
        public_card: $('#public_card')[0].checked ? 'yes' : 'no'
    },
    secureuri: false,
    fileElementId: 'fileToUpload',
    dataType: 'json',
    success: function (data, status) {
        alert(data);
    },
    error: function (data, status, e) {
        alert(e);
    }
});
Sign up to request clarification or add additional context in comments.

2 Comments

how PHP recieve public_card value? is it $_POST['public_card'];
@Giffary Yes, it should be there.

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.