I am trying to perform a file upload using JQuery and c#, but I am having a lot of problems. I can't figure out how to get the file to upload. It works fine if I use FileUpload, but I am allowing the user to dynamically add files, and so I am using Jquery (ajax post to another file) in order to process the file. First I was getting a POST and enctype error, but now it just isn't doing anything. Firebug is showing me that the ajax code is failing, but doesn't tell me anything else.
Here is my jquery:
function AddDocumentsDatabase() {
$('input:file').each(function (index) {
var fileName = $(this).val();
$.ajax(
{
type: "POST",
url: "../ajaxURLs/InsertDocument.aspx?requestNumber=" + reqNum + "&fileName=" + fileName,
contentType: 'multipart/form-data',
cache: false,
success: function (html) {
alert("File Inserted!")
}
}
);
});
}
And here is the InsertDocument.aspx code:
RequestDB db = new RequestDB();
ApplicationFunctions app = new ApplicationFunctions();
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Hello");
foreach (string key in Request.Form)
{
if (!key.StartsWith("fleBrowse")) continue;
{
Response.Write(Request.Form[key].GetType());
}
}
}
If it is something really easy, I apologize, my mind isn't running at full speed, right now. Any suggestions are greatly appreciated.