Example of Image Upload

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hanusoft
    Banned
    New Member
    • Sep 2007
    • 5

    #1

    Example of Image Upload

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


    Code (ImageUpload.as px.cs) :-
    [CODE=vb]private void Button1_Click(o bject sender, System.EventArg s e)
    {
    // Here I am uploading images in Images folder of C drive.
    int intResult=0;
    string strPath = @"c:\Images\"+P ath.GetFileName (File1.PostedFi le.FileName);
    SqlConnection con = new SqlConnection(" server=.;uid=sa ;database=pubs; pwd=");
    SqlCommand com = new SqlCommand("Ins ert into Category(name,i magepath) values(@name,@i magepath)",con) ;
    com.Parameters. Add("@name",Tex tBox1.Text);
    com.Parameters. Add("@imagepath ",strPath);
    con.Open();
    intResult = Convert.ToInt32 (com.ExecuteNon Query());
    if(intResult != 0)
    {
    File1.PostedFil e.SaveAs(strPat h);
    Response.Write( "Record Inserted.");
    }
    }[/CODE]
    Last edited by RedSon; Nov 6 '07, 05:32 PM. Reason: Deleteing URLs/CODE tags
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    The account of member hanusoft has been banned for a period of one week. Cross posting, failure to use code tags and spamming your website are against site rules. Please read the posting guidelines.

    -MODERATOR

    Comment

    Working...