Asp.net mvc 4 单击“打开”按钮而不是“提交”按钮时,HttpPostedFileBase传递给控制器

Asp.net mvc 4 单击“打开”按钮而不是“提交”按钮时,HttpPostedFileBase传递给控制器,asp.net-mvc-4,Asp.net Mvc 4,我的看法 当单击按钮HttpPostedFileBase没有文件时,它显示为null,但按钮用作提交它有文件,但单击按钮时我想要文件如果您想在没有提交按钮的情况下发布文件,那么您需要使用ajax,也可以通过传递到操作中的FormCollection访问文件。文件在此对象上有自己的属性。关于FormData,请记住这是行不通的。 <input type="file" data-val="true" id="file" name="file" style="width: 200px;" /

我的看法


当单击按钮HttpPostedFileBase没有文件时,它显示为null,但按钮用作提交它有文件,但单击按钮时我想要文件如果您想在没有提交按钮的情况下发布文件,那么您需要使用ajax,也可以通过传递到操作中的FormCollection访问文件。文件在此对象上有自己的属性。关于FormData,请记住这是行不通的。
<input type="file" data-val="true"  id="file" name="file" style="width: 200px;"  />
<input name="" type="button" value="Import file" class="Button_blue" id="ImportFile" />
public ActionResult BRSImport1(BRSImportModel objBRSImportModel, FormCollection fc, HttpPostedFileBase file)