.Net 文件上传如何获取文件的全路径
前台页面
<% using (Html.BeginForm("ContractUpFile", "Employees", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ %>
<div style="margin:0 5px 5px 20px;">
<fieldset style="height:280px; ">
<legend>上传合同信息</legend>
<p style=" position:absolute; margin-left:10px; margin-top:10px;">
<label for="upFile">选择上传合同文件:<a href="/Employees/ContractUpFileExcelDemo">下载模板</a></label>
<input type="file" name="upFile" style=" width:600px; height:25px;" /><br />
<input type="hidden" name="emp_no" id="emp_no" />
</fieldset>
</div>
<%}%>
后台代码:
public ActionResult ContractUpFile(HttpPostedFileBase upFile)
{
object fileName=upFile.FileName;//获取的是上传文件的文件名,不是全路径
}