Asp.net mvc 图像上载功能对我来说无法正常工作

Asp.net mvc 图像上载功能对我来说无法正常工作,asp.net-mvc,Asp.net Mvc,我是在一个教程的帮助下使用这段代码的,但是我仍然无法上传图像,我的意思是图像没有出现,请有人帮助我 这是我使用的代码:- <div class="col-md-6"> <div class="form-group"> @Html.LabelFor(model => model.ImgPath, htmlAttributes: new { @class = "control-label col-md-2" }) <div

我是在一个教程的帮助下使用这段代码的,但是我仍然无法上传图像,我的意思是图像没有出现,请有人帮助我

这是我使用的代码:-

<div class="col-md-6">
    <div class="form-group">
        @Html.LabelFor(model => model.ImgPath, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            <img src="@Url.Content(Model.ImgPath)" style="margin:10px" height="200" width="200" id="imagePreview" />
            <input type="file" name="ImageUpload" accept="image/jpeg, image/png" onchange="ShowImagePreview(this, document.getElementById('imagePreview')" />
        </div>
    </div>
</div>

@LabelFor(model=>model.ImgPath,htmlAttributes:new{@class=“controllabel col-md-2”})

如果您的图像没有上传,我认为您应该检查表单标签,并将其设置为如下内容

<form method="post" enctype="multipart/form-data">
//your image upload
<input type="file" name="ImageUpload" accept="image/jpeg, image/png" />
</form>

阅读这篇文章了解它

有人请帮助Hi Mitha,欢迎来到SO。你能清楚地说明你想完成什么吗?什么是ShowImagePreview?
//this for Asp.Net Core
public IActionResult(IFormFile ImageUpload)
{
   //Everything here
}

//Or this for Asp.Net
public ActionResult(HttpPostedFileBase ImageUpload)
{
   //Everything else here
}