Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Upload file and also how to download uploaded file in c# and file path is stored in MS Access during uploading ?
Posted
Comments
koolprasad2003 21-Sep-11 2:46am    
webbased / winform ?
Janardan Pandey 21-Sep-11 5:04am    
Web Based

you can see this
Click
 
Share this answer
 
C#
protected void btnSub_Click(object sender, EventArgs e)
   {
       try
       {
           string filename = FileUpload1.FileName;

           FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\Uploadform\\" + filename.Trim()));

           string path = "~\\Uploadform\\" + filename.Trim();

           OleDbConnection con = new OleDbConnection(str);//str is connection string
           cmd = new OleDbCommand("Insert into adminCircular(title,type,url1) values('" + txttitle.Text + "','" + txttype.Text + "','" + path + "')", con);
           lblinfo.Text = " Uploaded Successfully ";
           cmd.CommandType = CommandType.Text;
           con.Open();
           cmd.ExecuteNonQuery();
           con.Close();
       }
       catch (Exception ex)
       {
           Response.Write(ex.ToString());
       }
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900