Last post May 03, 2011 02:11 PM by email@example.com
Apr 13, 2011 02:46 AM|MrJx|LINK
how to auto resize image then upload??
any1 can help me?
below is my code:
If FileUpload1.HasFile Then
filename1 = FileUpload1.FileName
savePath1 += filename1
sSQL1 = "SELECT * from news order by PicID desc"
conn1 = New SqlConnection(ConnStr)
cmd1 = New SqlCommand(sSQL1, conn1)
rd1 = cmd1.ExecuteReader()
Dim n As Integer
n = rd1.Item("PicID") + 1
sSQL = "select * from news"
conn = New SqlConnection(ConnStr)
cmd = New SqlCommand(sSQL, conn)
da = New SqlDataAdapter(cmd)
cb = New SqlCommandBuilder(da)
ds = New DataSet
nrow = ds.Tables("news").NewRow()
nrow("PicID") = n
nrow("ImagePath") = "~/new/news_images/" + filename1
nrow("Tittle") = tittle
FileUpload1.SaveAs(Server.MapPath("/new/news_images/" & filename1))
lblmsg1.Text = "Image Upload Successful!"
Apr 13, 2011 03:17 AM|XIII|LINK
you first need to upload the image and the use GDI+ to resize it. There are a lot of articles about this:
Apr 14, 2011 04:25 AM|MrJx|LINK
May 03, 2011 02:11 PMfirstname.lastname@example.org|LINK
There is a free, open-source library to handle all the encoding and resizing issues. It supports uploads as well as MS SQL.
If you decide to roll your own, make sure you read the following article.
20 Image Resizing Pitfalls in .NET
A lot of the rookie mistakes are not obvious, and not documented well.