大家好我试图上传一个简单的图像,但HttpPostedFileBase总是剩余空。 这是我的代码,我不知道我做错了。
这是我在设计视图代码:
<fieldset>
<legend>PictureModel</legend>
<div class="editor-label">
<%: Html.LabelFor(model => model.PrivacyTypeID) %>
</div>
<div class="editor-field">
<%: Html.DropDownList("PrivacyTypeID", null, new { name = "PrivacyTypeID", title = "Please select privacy type.", id = "PrivacyTypeID" }) %>
<%: Html.ValidationMessageFor(model => model.PrivacyTypeID) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.File1) %>
</div>
<div class="editor-field">
**<input type="file" name="File1" />**
<%: Html.ValidationMessageFor(model => model.File1) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Description) %>
</div>
这里是在我的控制器代码:
公众的ActionResult给AddPicture(GUID ID,PictureModel模型,HttpPostedFileBase文件1){{尝试
if (ModelState.IsValid)
{
try
{
Guid albumid = id;
if (File1 != null)
{
var physicalPath = Path.Combine(Server.MapPath("~/Gallery"), System.IO.Path.GetFileName(File1.FileName));
File1.SaveAs(physicalPath);
PicturesBL pictures = new PicturesBL();
谁能告诉我这是什么问题?