Sunday 15 March 2015

How to save Uploaded file in the folded of Solution Exploer



Hello ,
            Friends  Now I am going to describe how to save uploaded file in the folder of Solution Exploer.
Please follow these steps.
Step-1:
Create a .aspx file of web application and design like this and follow up the following code.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body style="width: 285px">
    <form id="form1" runat="server">
    <div>
   
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Summit" />
        <br />
        <asp:Label ID="lblupload" runat="server" ForeColor="#FF33CC"></asp:Label>
   
    </div>
    </form>
</body>
</html>


Step-2:
Go to Solution Exploer  rightclick over your project then select Add option then select New Folder and rename it.Please follow according to following snapshot.
  Step-3:
After create a folder go to your design page(.aspx) and double click over Summit button and
Write the following code.
protected void Button1_Click(object sender, EventArgs e)
    {
        FileUpload1.SaveAs(Server.MapPath("rabi\\" + FileUpload1.FileName));
        lblupload.Text = "Thanks...Your File Uploaded Sucessfully...";
       
    }
Step-4:
After run this application Refresh it and check your file in this folder.
Thanks                                                                                  Rabi

No comments:

Post a Comment