最近做的项目跟ASP.NET上传文件内容有关,故将代码贴出,以便网友查阅,提供解决此类问题思路:如出现任何不理解问题,请留言,及时帮您解决!
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!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>
<body>
<form id="form1" runat="server">
<div style="border-right: #ffff00 thin dashed; border-top: #ffff00 thin dashed; margin-bottom: 4px; margin-left: 55px; border-left: #ffff00 thin dashed; line-height: normal; margin-right: 55px; padding-top: 1px; border-bottom: #ffff00 thin dashed; letter-spacing: normal; position: static; background-color: silver; text-align: center">
<br />
<asp:Label ID="LabelTitle" runat="server" Font-Bold="True" Font-Size="XX-Large" ForeColor="Black"
Text="上传管理"></asp:Label><br />
<br />
<asp:FileUpload ID="FileUpload1" runat="server" Width="369px"/>
<asp:Button ID="ButtonUp" runat="server" Height="21px" Text="上 传" Width="67px" OnClick="ButtonUp_Click" /><br />
<br />
<asp:Label ID="LabelTitle2" runat="server" ForeColor="Red" Text="*上传文件不能超过2M"></asp:Label><br />
<b>原文件名:</b><span id ="FileName" runat="server" /><br />
<b>上传到服务器:</b><span id="SaveDir" runat="server" /><br />
<b>缩略图地址:</b><span id ="sSaveDir" runat ="server" /><br />
<b>文件类型:</b><span id ="FileType" runat ="server" /><br />
<b>文件大小:</b><span id="FileLength" runat ="server" /><br />
<b>文件拓展名:</b><span id="FileExtention" runat="server" /><br />
<b>上传日期:<br /><span id ="UpDateTime" runat ="server" /><br />
图片预览:<br />
<asp:Image ID="Image1" runat="server" ImageUrl="~/Login.aspx" BorderColor="#0000C0"/><br />
</b>
<br />
<br />
</div>
</form>
</body>
</html>