Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...