Possible Duplicate:
Is it possible to use Ajax to do file upload?
I’m trying to upload the image using jquery ajax.I used Jquery Load function. I checked from firebug all the input fields are submitted except the image field that is type=file.
CakePhp Code
echo $this->Form->input('Testimonial.photo', array('type'=>'file', 'label'=>'Upload Avator'));
Jquery Function
$('a[rel=save]').live('click',function(clickEvent) {
clickEvent.preventDefault();
var url = $(this).attr('href');
$("#block").load(url, $("#form :input").serializeArray(),function(){
}
);
});
How can i overcome this issue?
input type="file"elements cannot be transferred using regular jQuery Ajax. You should take a look at the new File API in combination with “XMLHttpRequest level 2” that (unfortunately) is not supported by all modern browsers yet.Workaround: iframe or Flash solutions (search for “uploadify” for example).