I want to create File Upload Handler in VB.NET.
What I want to do is pass some 5 values and a file uploaded in file upload control through AJAX call using jQuery.
But my problem is I don't know how to pass these values + file to ASHX
and how to retrieve values in Generic HTTPHandler
.
What I've done yet is:
var fileType = '#' + $('input[type=file]')[0].id;
if (fileType != null && typeof(fileType)!='undefined')
{
document.getElementById('hdnFileName').value = $(fileType).val().split('\\').pop();
//document.getElementById('hdnFileName').value = $(fileType).val();
var files = fileUpload.files;
var data = new FormData();
for (var i = 0; i < files.length; i++) {
data.append(files[i].name, files[i]);
}
data.append(workspaceId, document.getElementById(HFWorkspaceId).value());
var options = {};
options.url = "FileUploadHandler.aspx";
options.type = "POST";
options.data = data;
options.contentType = false;
options.processData = false;
options.success = function (result) { alert(result); };
options.error = function (err) { alert(err.statusText); };
$.ajax(options);
$(fileType).attr('disabled','disabled');
}