Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP.NET (http://www.go4expert.com/forums/asp-net/)
-   -   Example of Image Upload (http://www.go4expert.com/forums/example-image-upload-t6455/)

hanusoft 20Sep2007 12:16

Example of Image Upload
 
Here we are uploading images in File System and storing path in the database.

Code (ImageUpload.aspx.cs) :-
Code:

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


shabbir 20Sep2007 14:52

Re: Example of Image Upload
 
So whats your query or its just you want to spam forums with the links to your site.


All times are GMT +5.5. The time now is 02:31.