Get a full file path sent by the client in mvc
Ajax Call
$("#btnCreateInvoice").click(function () {
var id = $("#QuotId").val();
var data = new FormData();
var files = $("#FileUpload").get(0).files;
if (files.length > 0) {
data.append("FileUpload", files[0]);
data.append("QuotId", id);
$.ajax({
type: "POST",
url: "/Invoice/CreateInvoice",
contentType: false,
processData:false,
data: data,
success: function (response) {
if (response.msg == "success") {
// windows.location.href = "/Home/Index";
window.location.href = '@Url.Action("Index", "Home")';
alert("Your Invoice has been successfully created with " + response.id);
}
},
error: function (response) {
alert(response);
}
});
}
});
ActionResult
public ActionResult CreateInvoice(string QuotId)
{
var httpPostedFile = Request.Files["FileUpload"];
var id = Request.Form["QuotId"];
var filename = Path.GetFullPath(httpPostedFile.FileName);
}
Actually the correct uploaded path file path is
E:\TrainingPrj\TrainingProject\Images\signlogo.jpg
and it shows me
C:\Program Files\IIS Express\signlogo.jpg