MVC 4中的图像上传控制 [英] image upload control in MVC 4
本文介绍了MVC 4中的图像上传控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我上传图像然后点击保存按钮图像时,我有一个图像上传控件可以保存到数据库中。我怎么能在MVC 4中执行?
I have a Image upload control when i uploading image then click on save button image can be saving into Data base." how can i do it in MVC 4?
推荐答案
试试这个
Try this
@using (Html.BeginForm("YourAction", "YourController", FormMethod.Post, new { enctype = "multipart/form-data"}))
{
//You Upload control
<div class="editor-field" style="margin-removed10px">
<input type="file" style="width: 328px;height:25px" name="myUploadControlName" />
//Please make sure that the name of the upload control should be same as the second argument name in the Create action result.
</div>
}
Your ActionResult
[HttpPost]
public ActionResult Create(IfAnyModelClass model, System.Web.HttpPostedFileBase myUploadControlName)
{
//from this HttpPostedFileBase you get the upload information
}
希望这有帮助
Hope this helps
这篇关于MVC 4中的图像上传控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文