When i try to upload an image file using the jquery post. my jquery for post given below.
$(document).ready(function(){
$('#submit_img').bind("click",function(){
if(validateProfile()){
//alert(img);
var img = new FormData();
img.append('file',[].files[0]);
//$('#file_upload')[0].files[0];
$.post(profileUrl,{'api_key':apiKey,
'api_secret':apiSecret,
'id_user': userid,
'profile_image':img,
},function(data){
$.each($.parseJSON(data),function(key,value){
var stStatus = value.status;
var stText = value.status_text;
alert(stText);
//$("#error_username").html(stText);
});
});
}
});
});
When pressing the submit button give the error lke this "TypeError: [].files is undefined" I dont know the what the exact reason . I am new to jquery.