我正在使用ASP.NET MVC4来开发一个Intranet应用程序。其中一个主要功能是允许用户上传将存储在我的数据库中的文件。为了做到这一点,我使用jQuery。但是,我不知道我必须做什么才能操纵上传的文件。我已经知道,我必须操纵他们进入通讯员控制器,但在阅读了互联网上的一些提示后,我看不出我该怎么做。MVC4检索上传的文件
这是我的观点:
@model BuSIMaterial.Models.ProductAllocationLog
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>ProductAllocationLog</legend>
<div class="editor-label">
Date :
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Date, new { @class = "datepicker"})
@Html.ValidationMessageFor(model => model.Date)
</div>
<div class="editor-label">
Message :
</div>
<div class="editor-field">
@Html.TextAreaFor(model => model.Message)
@Html.ValidationMessageFor(model => model.Message)
</div>
<div class="editor-label">
Allocation :
</div>
<div class="editor-field">
@Html.DropDownList("Id_ProductAllocation", String.Empty)
@Html.ValidationMessageFor(model => model.Id_ProductAllocation)
</div>
<div class="demo" style="float:left; margin-top:5px;">
<div id="aupload" style = "border:2px dashed #ddd; width:100px; height:100px; margin-right:10px; padding:10px; float:left;"></div>
<div id="uploaded" style = "border: 1px solid #ddd; width:550px; height:102px; padding:10px; float:left; overflow-y:auto;"></div>
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
我是绝对不要求预制的代码示例,但只是一种方式来进行。这将是非常善良。
谢谢,我会试试看。 – Traffy 2013-03-20 11:58:17