# Example of Image Upload

**URL:** https://forum.kirupa.com/t/example-of-image-upload/239711
**Category:** programming
**Created:** [September 25, 2007, 8:03am UTC](https://forum.kirupa.com/t/example-of-image-upload/239711 "2007-09-25T08:03:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hanusoft](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hanusoft](https://forum.kirupa.com/u/hanusoft)
#### Post date: [September 25, 2007, 8:03am UTC](https://forum.kirupa.com/t/example-of-image-upload/239711/1 "2007-09-25T08:03:13Z")

</div>

Here we are uploading images in File System and storing path in the database.

> **[Managed Services Consultants | Hanu Software Solutions, Inc.](https://hanusoftware.com/)**
>
> Hanu helps all types of customers by accelerating innovation with truly custom Azure-based cloud services. Contact Us Today to Learn More.

Code (ImageUpload.aspx.cs) :-  
private void Button1\_Click(object sender, System.EventArgs e)  
{  
// Here I am uploading images in Images folder of C drive.  
int intResult=0;  
string strPath = @“c:\Images”+Path.GetFileName(File1.PostedFile.FileName);  
SqlConnection con = new SqlConnection(“server=.;uid=sa;database=pubs;pwd=”);  
SqlCommand com = new SqlCommand(“Insert into Category(name,imagepath) values(@name,@imagepath)”,con);  
com.Parameters.Add("@name",TextBox1.Text);  
com.Parameters.Add("@imagepath",strPath);  
con.Open();  
intResult = Convert.ToInt32(com.ExecuteNonQuery());  
if(intResult != 0)  
{  
File1.PostedFile.SaveAs(strPath);  
Response.Write(“Record Inserted.”);  
}  
}
