.aspx
<script type="text/javascript">
 function addfile()
 {
 var str='<INPUT ><br>'
 document.getElementById('myfile1').insertAdjacentHTML("beforeEnd",str)   
 }  
</script>
 
<table width="500" align="center">
     <tr>
           <td valign="top" width="120">
                 <asp:Label ID="lblselect" runat="server" Text="请选择文件路径"></asp:Label>
           </td>
           <td width="266">
                 <p >
                 <input >
                 </P> 
            </td>
            <td valign="top">
                 <input style="BORDER-RIGHT: 1px ridge; BORDER-TOP: 1px ridge; BORDER-LEFT: 1px ridge; WIDTH: 75px; BORDER-BOTTOM: 1px ridge; HEIGHT: 20px"  onclick="addfile()" type="button" size="14" value="New Control">                            
            </td>
     </tr>
     <tr>
            <td></td>
            <td>
                 <asp:Button ID="btnload" runat="server" Height="22px" Text="导入系统"  Width="64px" onclick="btnload_Click" />
                 <asp:Button ID="Btncancel" runat="server" Height="22px" Text="取  消" />
                 <asp:Button ID="Btnclose" runat="server" Height="22px" Text="关  闭" onclick="Btnclose_Click" />
            </td>
            <td></td>
     </tr>
</table>
 
.cs
protected void Load_File()
{
        HttpFileCollection files = HttpContext.Current.Request.Files;
        try
        {
            for (int iFile = 0; iFile < files.Count; iFile++)
            {
                HttpPostedFile postedFile = files[iFile];
                string filename, strServerFileName;//, fileExtension;
                filename = System.IO.Path.GetFileName(postedFile.FileName);
                if (filename != "")
                {
                    //fileExtension = System.IO.Path.GetExtension(filename);获取filename文件扩展名                   
                    strServerFileName =System.IO.Path.GetDirectoryName(Server.MapPath("login.aspx")) + "\\Bom\\" + filename;
                    //将WebForm1.aspx所在的文件目录\上传的文件名赋给strServerFileName变量
                    postedFile.SaveAs(strServerFileName);//保存上载文件的内容                   
                    ReadExcel(strServerFileName, GridView1);
                }
            }
            this.RefreshOpener();
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
            return;
        }
    }

相关文章:

  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-10
  • 2021-06-04
猜你喜欢
  • 2022-02-20
  • 2022-12-23
  • 2021-11-30
  • 2021-06-09
  • 2021-12-29
  • 2021-12-19
  • 2022-01-22
相关资源
相似解决方案