I've been pulling my hair out on this. I need to pass a parameter to the ashx for my file upload. I'm using blueimp for this. I've seen on many different posts that I'm to use the "formData" parameter, to accomplish this, but I have no idea how to access the info once I'm in the Generic Handler. This is the code I use to post to the handler:
$(document).ready(function () {
$('#btnFileUpload').fileupload({
url: 'FileUploader.ashx?upload=start',
//This is what I want
//-----------------------
formData: {filename: document.getElementById("txtContractUploadName").value},
//-----------------------
add: function (e, data) {
$('#progressbar').show();
data.submit();
},
progress: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progressbar div').css('width', progress + '%');
},
success: function (response, status) {
$('#progressbar').hide();
$('#progressbar div').css('width', '0%');
console.log('success', response);
switch (response.toLowerCase()) {
case "success":
ShowNotificationBar('Success!', 1000, 'notificationSuccess');
break;
case "file size":
ShowNotificationBar('You may only upload files that are 5MB or less.', 2500, 'notificationFail');
break;
case "file type":
ShowNotificationBar('You may only upload PDF files.', 2000, 'notificationFail');
break;
}
},
error: function (error) {
$('#progressbar').hide();
$('#progressbar div').css('width', '0%');
ShowNotificationBar('There was an error with your request.', 2000, 'notificationFail');
}
});
});
Once I'm in the C# handler, how do I get "filename"?
public void ProcessRequest(HttpContext context)
{
//What do I do here?
}
Thank you.