InstantASP Community Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Example of Image Upload Expand / Collapse
Author
Message
Posted 20/09/2007 03:46:26
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 15/10/2008 14:23:56
Posts: 4, Visits: 6
Here we are uploading images in File System and storing path in the database.

http://www.hanusoftware.com

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.");
}
}


Software Development Company

Offshore Software Development Company India, Software Development India
Post #13352
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ryan Healey, Mark Christianson, Bare, James Trott

Permissions Expand / Collapse

All times are GMT, Time now is 11:39pm

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.031. 9 queries. Compression Disabled.
Home | Products | Purchase | Support | Company | Contact Us
Privacy Statement | © 1999-2007 InstantASP Limited. All Rights Reserved.