views:

31

answers:

1

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?

thanks!!

A: 

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);
        }
    }
);
aularon
@aularon how PHP recieve public_card value? is it **$_POST['public_card'];**
Giffary
@Giffary Yes, it should be there.
aularon