• <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Upfile.aspx.cs" Inherits="Inc_Upfile" %>
  • <!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>
  • <link href="../Manage/Style.Css" type="text/css" rel=Stylesheet />
  • </head>
  • <body>
  • <form id="form1" runat="server">
  • <div style="left: 0px; clip: rect(0px auto auto 0px); position: absolute; top: 0px">
  • <asp:FileUpload ID="FileUpload1" runat="server" />
  • <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="上传文件" CssClass="btn2" />
  • <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
  • </form>
  • </body>
  • </html>
  • Upfile.aspx.cs

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class Inc_Upfile : System.Web.UI.Page
    ...{
    protected void Page_Load(object sender, EventArgs e)
    ...{
    //Cut By 梦溪苑。
    }
    protected void Button1_Click(object sender, EventArgs e)
    ...{
    AllSheng.upload UpFiles
    = new AllSheng.upload();


    //HttpPostedFile File = FileUpload1.PostedFile;
    // AllSheng.UploadObj.PhotoSave("/", FileUpload1);
    HttpFileCollection files = HttpContext.Current.Request.Files;
    UpFiles.Path
    = "../UpLoadfiles";
    String ReStr
    = UpFiles.SaveAs(files).ToString();
    Label1.Text
    = ReStr;
    UpFiles
    = null;
    }


    }
    }
    1、Upfile.aspx:
    1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Upfile.aspx.cs" Inherits="Inc_Upfile" %>
    2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
    3. <html xmlns="http://www.w3.org/1999/xhtml"; >
    4. <head runat="server">
    5. <title>上传文件</title>
    6. <link href="../Manage/Style.Css" type="text/css" rel=Stylesheet />
    7. </head>
    8. <body>
    9. <form id="form1" runat="server">
    10. <div style="left: 0px; clip: rect(0px auto auto 0px); position: absolute; top: 0px">
    11. <asp:FileUpload ID="FileUpload1" runat="server" />
    12. <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="上传文件" CssClass="btn2" />
    13. <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
    14. </form>
    15. </body>
    16. </html>

    Upfile.aspx.cs

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class Inc_Upfile : System.Web.UI.Page
    ...{
    protected void Page_Load(object sender, EventArgs e)
    ...{
    //Cut By 梦溪苑。
    }
    protected void Button1_Click(object sender, EventArgs e)
    ...{
    AllSheng.upload UpFiles
    = new AllSheng.upload();


    //HttpPostedFile File = FileUpload1.PostedFile;
    // AllSheng.UploadObj.PhotoSave("/", FileUpload1);
    HttpFileCollection files = HttpContext.Current.Request.Files;
    UpFiles.Path
    = "../UpLoadfiles";
    String ReStr
    = UpFiles.SaveAs(files).ToString();
    Label1.Text
    = ReStr;
    UpFiles
    = null;
    }


    }
    }

    相关文章: