Monday, October 27, 2014

upload file in html

Posted by Unknown  |  No comments

 how to write code for browse button in c#.net  
 ------------------------------------------------:  
 for any quires or any type of code visit   
 http://scriptquery.blogspot.in/  
 http://scriptquery.blogspot.in/  
 logon to facebook please like and share scriptquery in facebook  
 just fallow these step :  
 step 1:)  
 ----------  
 <body>  
 <form id="form1" runat="server">  
 <div>  
 <h3> File Upload:</h3>  
 <br />  
   <asp:FileUpload ID="FileUpload1" runat="server" />  
   <br /><br />  
   <asp:Button ID="btnsave" runat="server"   
         onclick="btnsave_Click" Text="Save"   
         style="width:85px" />  
   <br /><br />  
   <asp:Label ID="lblmessage" runat="server" />  
 </div>  
 </form>  
 </body>  
 step 2:)  
 ----------  
 protected void btnsave_Click(object sender, EventArgs e)  
 {  
   StringBuilder strbuild = new StringBuilder();  
   if (FileUpload1.HasFile)  
   {  
    try  
    {  
    strbuild .AppendFormat(" Uploading file: {0}",   
                  FileUpload1.FileName);  
    //saving the file  
    FileUpload1.SaveAs("<c:\\SaveDirectory>" +   
                  FileUpload1.FileName);  
    //Showing the file information  
    strbuild .AppendFormat("<br/> Save As: {0}",   
              FileUpload1.PostedFile.FileName);  
    strbuild .AppendFormat("<br/> File type: {0}",    
              FileUpload1.PostedFile.ContentType);  
    strbuild .AppendFormat("<br/> File length: {0}",   
              FileUpload1.PostedFile.ContentLength);  
    strbuild .AppendFormat("<br/> File name: {0}",   
              FileUpload1.PostedFile.FileName);  
    }  
    catch (Exception ex)  
    {  
    sb.Append("<br/> Error <br/>");  
    sb.AppendFormat("Unable to save file <br/> {0}",   
              ex.Message);  
    }  
   }  
   else  
   {  
    lblmessage.Text = strbuild .ToString();  
   }  
 }  
 for any quires or any type of code visit   
 http://scriptquery.blogspot.in/  
 http://scriptquery.blogspot.in/  
 logon to facebook please like and share scriptquery in facebook  

6:07 AM Share:

0 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top