<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>上传文件</title> </head> <base target="_self"> <body style="margin: 0px"> <div> <%using (Html.BeginForm("UploadFile","File",FormMethod.Post,new {enctype="multipart/form-data"})) {%> <table align="center" style="top: 15px; position: relative;"> <tr> <th nowrap=nowrap>请选择文件</th> <td><input type="file" name="file" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td align="center" colspan=2> <a IconCls="icon-ok" class="easyui-linkbutton" href="#" onclick="UploadFile();" plain="false">确定</a> <a IconCls="icon-no" class="easyui-linkbutton" href="#" onclick="window.close();return false;" plain="false">取消</a> </td> </tr> </table> <% }%> </div> <%Html.RenderPartial("../Shared/Scripts"); %> <script language="javascript" type="text/javascript"> //上传文件 function UploadFile() { if (document.getElementById("file").value == "") { MSI("提示", "请选择要上传的文件"); return false; } var filename = document.getElementById("file").value; var index = filename.lastIndexOf("."); if (index == -1) { MSI("提示", "文件格式异常"); return false; } var ext = filename.substr(index + 1); if (ext.toLowerCase() != "xls" && ext.toLowerCase() != "xlsx") { MSI("提示", "请上传excel文件"); return false; } submitByButton("UploadFile"); return true; } </script> </body> </html>