hey i am have made a form for product detail insertion . I am using ajax in asp.net in order to insert data in database. Now in my form of the controls is fileupload control. Problem is i dont know how to select the file and pass it to the static method for operations like hasfile, etc. so is it possible that i pass the file using ajax technique and can store it's detail in database.
<asp:FileUpload ID="file_image" runat="server" />
$(document).ready(function () {
$("#submit").click(function () {
var cat = document.getElementById('DropDownList1').value;
var nm = document.getElementById('name').value;
var code = document.getElementById('code').value;
var dt = document.getElementById('dt').value;
var price = document.getElementById('price').value;
alert("you clicked " + cat + " - " + nm + "-" + code + "-" + dt + "-" + price + "-");
var fl = document.getElementById('file_image').value;
//this line is the problem as i can't get file
$.ajax({
method: "POST",
contentType: "application/json",
url: "~/home.aspx/insert",
dataType: "json",
// data: "{'Name':'" + document.getElementById('name').value + "'}",
data:"{}",
//async: false,
success: function (response) {
alert("User has been added successfully.");
window.location.reload();
}
});
})
});