FileUpload img = (FileUpload)FileUpload4;
Byte[] imgByte = null;
if (img.HasFile && img.PostedFile != null)
{
HttpPostedFile File = FileUpload4.PostedFile;
imgByte = new Byte[File.ContentLength];
File.InputStream.Read(imgByte, 0, File.ContentLength);
}
con.Open();
string sql = "INSERT INTO randomimage VALUES(@imgexplain,@imgtype)";
SqlCommand cmd1 = new SqlCommand(sql, con);
cmd1.Parameters.AddWithValue("@imgexplain", TextBox7.Text.Trim());
cmd1.Parameters.AddWithValue("@imgtype", imgByte);
int id = Convert.ToInt32(cmd1.ExecuteNonQuery());
Label17.Text = String.Format("Success to add");
this is the coding i using for storing the image ,when i display that how can i reduce the size of it?
plese tell me
Loading
Suthish NairPosted Mar 12, 2011, 12:59 PM
Guest UserPosted Mar 10, 2011, 10:21 AM
Mahesh ChandPosted Mar 10, 2011, 10:15 AM
Inserting & retrieving images from SQL Server database using stored procedures
Inserting & Retrieving Images from SQL Server Database without using Stored Procedures
In this article, there is a line of code:
pictureBox1.Image = Image.FromStream(ms);
This code basically gets the data from database in a steam and converts it to an Image object.
So you need to replace this something like this:
Image changedSize = Image.FromStream(ms);
Now you need to create a thumbnail with a different size.
Here are two articles on it:
Create a thumbnail in C#
Create Image Thumbnails in C#