Javascript 在asp.net webapi中以排除格式在节目中上载图像
我已经写了上传档案图片的代码,但上传文件后,它会被排除在我上传的文件夹中。如何包括这一点,或者你有任何其他的解决方案来上传文件Javascript 在asp.net webapi中以排除格式在节目中上载图像,javascript,asp.net,asp.net-mvc-4,asp.net-web-api2,Javascript,Asp.net,Asp.net Mvc 4,Asp.net Web Api2,我已经写了上传档案图片的代码,但上传文件后,它会被排除在我上传的文件夹中。如何包括这一点,或者你有任何其他的解决方案来上传文件 $("#btnUploadFile").click(function (evt) { alert('dfdfd'); var imgup = 'img'; var files = $("#fileUpload").get(0).files; if (files.l
$("#btnUploadFile").click(function (evt) {
alert('dfdfd');
var imgup = 'img';
var files = $("#fileUpload").get(0).files;
if (files.length > 0) {
var data = new FormData();
for (i = 0; i < files.length; i++) {
data.append("file" + i, files[i]);
}
$.ajax({
type: "POST",
url: '/api/EmployeeMasterApi/UploadFile/'+'?imgup' + imgup,
contentType: false,
processData: false,
data: data,
// data: JSON.stringify(data),
success: function (messages) {
for (i = 0; i < messages.length; i++) {
alert('dddd');
alert(messages[i]);
}
},
error: function () {
alert("Error while invoking the Web API");
}
});
}
});
这里工作很好。上传imgUpload文件夹中的图像后,将以排除格式显示。请帮助解决此问题排除格式是什么意思?
[HttpPost]
public void UploadFile([FromUri] string[] imgup)
{
if (HttpContext.Current.Request.Files.AllKeys.Any())
{
// Get the uploaded image from the Files collection
var httpPostedFile = HttpContext.Current.Request.Files["file0"];
if (httpPostedFile != null)
{
// Validate the uploaded image(optional)
// Get the complete file path
var fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath("~/imgUpload"), httpPostedFile.FileName);
// Save the uploaded file to "UploadedFiles" folder
httpPostedFile.SaveAs(fileSavePath);
}
}
}