0

Possible Duplicate:
Javascript file uploads

I am using jQuery post to Post data to a PHP file. It's working fine for the input text,textarea. But I want it to work with input type file as well. Here's my code, how can I adapt it?

<input type="file" name="image">

$.ajax({
    type : "post" ,
    url :  LIB_PATH + "sharefund/sharefund.php" ,
    data : $("form[name=sharefunds]").serialize() ,
    dataType : "json",
    success : function(retData){
        alert(retData);
        if(retData != null && retData.hasOwnProperty("response"))
        {
            if(retData.response.code == '400')
            {
                $("span.error").html("Unable to update address, please try again later .").show();
            }
            if(retData.response.code == '200')
            {
                $("span.error").html("Your address has been updated successfully.").css('color' , 'green').show();
            }
        }

        __removeOverlay();
        setTimeout(function(){
            $("span.error").slideUp();
        }, 5000);
    }   
});
Community
  • 1
  • 1
user867453
  • 21
  • 1
  • 6

1 Answers1

0

You can not get the input type file in the jquery form serialization . you have to use the plugins for the ajax file upload.

muthu
  • 5,381
  • 2
  • 33
  • 41