I\'m trying to upload an image file with jQuery AJAX and a generic handler. But it seems that the file isn\'t being passed to the handler.
After submit context.Request
Managed to get this working :)
Here's my code...
///create a new FormData object
var formData = new FormData(); //var formData = new FormData($('form')[0]);
///get the file and append it to the FormData object
formData.append('file', $('#file')[0].files[0]);
///AJAX request
$.ajax(
{
///server script to process data
url: "fileupload.ashx", //web service
type: 'POST',
complete: function ()
{
//on complete event
},
progress: function (evt)
{
//progress event
},
///Ajax events
beforeSend: function (e) {
//before event
},
success: function (e) {
//success event
},
error: function (e) {
//errorHandler
},
///Form data
data: formData,
///Options to tell JQuery not to process data or worry about content-type
cache: false,
contentType: false,
processData: false
});
///end AJAX request
When I implement such a thing, I use
var fd = new FormData();
fd.append(file.name,file);
And in the ajax call, send the fd
.