I want to upload a image with a description like:
data = '{"filename":"' + myfilename + '", "file":"' + file + '", "description":"' +
description + '"}';
$.ajax({
type: "POST",
url: "filehandler.ashx",
data: data,
success: function (result) {
alert(result);
},
error: function () {
alert("There was error uploading file!");
}
});
how can I do it? I can't read file as HttpPostedFile
in generic handler.
context.Request.Form
also doesn't have any keys.
I'm sorry, If I not posted fully what I did in question. Anyway I got it to work.
var data = new FormData();
data.append("name", filename);
data.append("file", file);
In generic handler
HttpPostedFile file = context.Request.Files["file"];
string fileName = context.Request.Form["filename"];