ASP.NET简单文件上传

aspx代码 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UploadFile.aspx.cs" Inherits="testNet.Re.UploadFile" %>

<!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>
    
<title>简单文件上传</title>
<script type="text/javascript" src="/js/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
var fupExcel;
var hfldFilePath;

$().ready(
function()
{   
    fupExcel 
= $("#<%= fupExcel.ClientID %>");
    hfldFilePath 
= $("#<%= hfldFilePath.ClientID %>");
    btnUpload 
= $("#<%= btnUpload.ClientID %>");
    
    btnUpload.click(
function()
    {
        hfldFilePath.val(fupExcel.val());
    });
});
</script>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        
<asp:FileUpload ID="fupExcel" runat="server" />
        
<asp:Button ID="btnUpload" runat="server" Text="上传" OnClick="btnUpload_Click" />
        
<asp:HiddenField ID="hfldFilePath" runat="server" />
        
<br />
        
<asp:TextBox ID="txtFilePath1" runat="server" Width="262px"></asp:TextBox><br />
        
<asp:TextBox ID="txtFilePath2" runat="server" Width="262px"></asp:TextBox>
        
<br />
        
<asp:Label ID="lblMessage" runat="server"></asp:Label></div>
    
</form>
</body>
</html>

cs代码

Code
原文地址:https://www.cnblogs.com/llcto/p/1376353.html