【发布时间】:2017-10-22 23:39:46
【问题描述】:
我正在使用 asp.net mvc-5 HttpPostedFileBase 进行文件上传,但在我选择图像后显示 HttpPostedFileBase 为空
这是我的代码
<input type="file" title="search image" file-model="profileimage" id="allfilepath" name="file" />
<button type="submit" class="btn btn-primary col-sm-5">
<span class="glyphicon glyphicon-plus"></span>
</button>
和我的控制器
[HttpPost]
public ActionResult insert(HttpPostedFileBase file, quotationcompany quotecomp)
{
var allowedExtensions = new[] {
".Jpg", ".png", ".jpg", "jpeg"
};
if (file == null)
{
ViewBag.message = "Please Select Image";
return View();
}
else {
ViewBag.message = "Image Uploaded Successfully";
return View();
}
}
if (file == null)(在我上传 png 图像后,这一行 (
file) 显示为 null)
这段代码有什么问题?
【问题讨论】:
-
一个建议!请在发布重复问题之前使用Search,否则您的问题可能会被否决(因为您已经有 9 个问题),这可能会导致您Question Ban
标签: asp.net-mvc file-upload asp.net-mvc-5 httppostedfilebase