前台HTML代码:
<form id="fm_debugPumpparams" action="/ajax/Debug.ashx" method="post" enctype="multipart/form-data">
<table>
<tr>
<td><input class="easyui-filebox" id="paramFile" name="paramFile" data-options="prompt:'参数文件...'" buttonText="浏览" buttonIcon="icon-search"/></td>
</tr>
</table>
</form>
注意:一定要加
enctype="multipart/form-data"
后台Debug.ashx代码:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
HttpPostedFile paramFile = context.Request.Files["paramFile"];
if (paramFile != null)
{
String fileName = paramFile.FileName;
fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1);
String savePath = context.Server.MapPath("~/txt/") + fileName;
paramFile.SaveAs(savePath);
}
}