我有一个 cshtml 文件用于将文件上传到服务器。
@using (Html.BeginForm("FileUpload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary();
<div class="alert alert-success alert-dismissible" role="alert">@ViewBag.Message</div>
<div class="form-horizontal">
<h4>Upload Data Documents</h4>
<hr />
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.project_id)
<div class="form-group">
<label class="control-label col-md-2">Some Other File</label>
<div class="col-md-10">
<input type="file" name="someOtherFile" class="form-control" />
<span class="field-validation-error" id="spanfilesomeOtherFile"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Results Comparison</label>
<div class="col-md-10">
<div class="form-group">
<div class="col-md-4">
<input type="file" name="FileUploadResultsComparison" class="form-control" placeholder=".col-md-4"/>
<span class="field-validation-error" id="spanfileResultsComparison"></span>
</div>
<div class="col-md-4">
@if (ViewData["Project"] != null)
{
@Html.DropDownList("resultsComp_project", …Run Code Online (Sandbox Code Playgroud) validation asp.net-mvc file-upload multipartform-data html.beginform