Tuesday, September 11, 2018

FileUPLOAD CONTROL SIMPLE WAY FOR UPLOADING FILE

HOSTED CODE ONLY 

if (!IsPostBack)
        {

            FileUpload1.Attributes["onchange"] = "UploadFile(this)";
        }


 protected void Upload(object sender, EventArgs e)
    {
        FileUpload1.SaveAs(Server.MapPath(@"~/Admin/") + "//member//" + FileUpload1.FileName);
         Label1.Text = FileUpload1.FileName;
        Image1.ImageUrl = "/Admin/member/" + Label1.Text;
       
    }



ASPX   CODE 

<HEAD>
  <script type="text/javascript">
        function UploadFile(fileUpload) {
            if (fileUpload.value != '') {
                document.getElementById("<%=btnUpload.ClientID %>").click();
            }
        }
</script>
</HEAD>





 <asp:FileUpload ID="FileUpload1" runat="server"/><br />

<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="Upload" Style="display: none" />





No comments:

Post a Comment

GRIDVIEW ON ROW DATA BOUND EVENT

 Database Create  Student : roll , name , city , cost  Fix 6 Value  in Database Record  ====================================================...