asp.net_ File Upload Control FileUpload usage Preliminary

Source: Internet
Author: User

1.aspx

            <asp:fileupload id= "fudtest" runat= "Server"/> <asp:button "id=" btnupload "
            server" runat= "upload" onclick= "Btnupload_click"/> <br/> <asp:label id= "lblmessage"
            runat= "Server" ></asp: Label>

1.aspx.cs

Upload file button protected void Btnupload_click (object sender, EventArgs e) {//define save path string Savepath = "

        Uploadfiles "; Whether there is a directory if (! System.IO.Directory.Exists (Server.MapPath (Savepath))) {//No Create folder exists System.IO.Directory.Cr
        Eatedirectory (Server.MapPath (Savepath)); ///Upload file if (fudtest.hasfile) {try {fudtest.saveas (serv) Er.

                MapPath (savepath) + "\" + fudtest.filename); Lblmessage.text = lblmessage.text+ "Client path: + fudTest.PostedFile.FileName +" <br> "+" FileName: "+ System.IO.Path.GetFileName (fudtest.filename) +" <br> "+" file name extension: "+ System.IO. Path.getextension (fudtest.filename) + "<br>" + "File Size:" + fudTest.PostedFile.ContentLe Ngth + "kb<br>" + "file MIME type:" + FudTest.PostedFile.ContentType + ";br> "+" Save path: "+ Server.MapPath (savepath) +" \ "+ fudtest.filename+

            "
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.