视图: <div class="form-group">
@Html.LabelFor(model => model.tupian, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="file" name="tupian1" />
@Html.ValidationMessageFor(model => model.tupian, "", new { @class = "text-danger" })
</div>
</div>
控制器: var file= Request.Files["tupian1"];——定义一个变量接收图片
string fileName = Guid.NewGuid().ToString("N") + System.IO.Path.GetExtension(file.FileName);——随机生成新文件名+原文件名的后缀