日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

建立家用服务器|软件站|第三日

發布時間:2025/3/15 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 建立家用服务器|软件站|第三日 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

相比音樂上傳,修改了只能上傳4M文件的情況。

通過編輯web.config來做到的。

下面是代碼:

uploadfiles.aspx 1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="uploadfiles.aspx.cs" Inherits="uploadfiles" %> 2 3 <!DOCTYPE html> 4 5 <html> 6 <head runat="server"> 7 <title></title> 8 </head> 9 <body> 10 <asp:Literal ID="Literal1" runat="server"></asp:Literal> 11 <hr /> 12 <form method="post" runat="server"> 13 <asp:FileUpload ID="FileUpload1" runat="server" /> 14 <asp:Button ID="Button1" runat="server" Text="上傳文件" οnclick="Button1_Click" /> 15 </form> 16 17 </body> 18 </html> uploadfiles.aspx.cs 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 using System.IO; 8 using System.Text; 9 10 public partial class uploadfiles : System.Web.UI.Page 11 { 12 protected void Page_Load(object sender, EventArgs e) 13 { 14 DirectoryInfo dir = new DirectoryInfo(Server.MapPath("./files")); 15 FileInfo[] files = dir.GetFiles("*.*"); 16 StringBuilder sb = new StringBuilder(); 17 for (int i = 0; i < files.Length; i++) 18 { 19 20 sb.Append("<a href='" + "files/" + files[i].Name + "'>" + files[i].Name + "</a><br />"); 21 } 22 Literal1.Text = sb.ToString(); 23 } 24 protected void Button1_Click(object sender, EventArgs e) 25 { 26 if (FileUpload1.FileName != "" && FileUpload1.FileName != null) 27 { 28 string filepath = FileUpload1.FileName; 29 filepath = Server.MapPath("./files") + "\\" + filepath; 30 FileUpload1.SaveAs(filepath); 31 } 32 33 DirectoryInfo dir = new DirectoryInfo(Server.MapPath("./files")); 34 FileInfo[] files = dir.GetFiles("*.*"); 35 StringBuilder sb = new StringBuilder(); 36 for (int i = 0; i < files.Length; i++) 37 { 38 39 sb.Append("<a href='" + "files/" + files[i].Name + "'>" + files[i].Name + "</a><br />"); 40 } 41 Literal1.Text = sb.ToString(); 42 43 } 44 } web.config <?xml version="1.0"?> <!--有關如何配置 ASP.NET 應用程序的詳細信息,請訪問http://go.microsoft.com/fwlink/?LinkId=169433--> <configuration><system.web><httpRuntime executionTimeout="600" maxRequestLength="951200" useFullyQualifiedRedirectUrl="true" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/> <compilation debug="true" targetFramework="4.0"/></system.web> </configuration>

這很簡單,甚至是粗劣。以后再繼續完善。

轉載于:https://www.cnblogs.com/yexinwei/archive/2013/01/17/2864352.html

總結

以上是生活随笔為你收集整理的建立家用服务器|软件站|第三日的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。