Example of Image Upload

hanusoft's Avatar, Join Date: Sep 2007
Light Poster
Here we are uploading images in File System and storing path in the database.

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);
	intResult =  Convert.ToInt32(com.ExecuteNonQuery());
	if(intResult != 0)
		Response.Write("Record Inserted.");

Last edited by shabbir; 20Sep2007 at 14:52.. Reason: Code block and Links removed
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
So whats your query or its just you want to spam forums with the links to your site.