i want to create a fileupload with ajax and jquery.i send formData to server.i can not get data and save image on server. it is my code in javascript:
function UploadFile() {
var fileName = $('#uploadFile').val().replace(/.*(\/|\\)/, '');
if (fileName != "") {
var formData = new FormData();
formData.append('file', $('input[type=file]')[0].files[0]);
$.ajax({
url: 'p1.aspx/uploadPic',
data: formData,
processData: false,
contentType: false,
type: 'POST',
success: function (dt) {
alert(dt.d);
}
});
}
}
code in p1.aspx page:
[WebMethod]
public static string uploadPic(HttpPostedFile file)
{
return file.FileName;
}
it is not work and not return any thing!what is wrong?how can get image on server? best reagrds.