Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 03, 2011 06:11 PM by nathanael.jones@gmail.com
Member
219 Points
126 Posts
Apr 13, 2011 06:46 AM|LINK
how to auto resize image then upload??
any1 can help me?
thanks
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) conn1.Open() rd1 = cmd1.ExecuteReader() rd1.Read() 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 da.Fill(ds, "news") nrow = ds.Tables("news").NewRow() nrow("PicID") = n nrow("ImagePath") = "~/new/news_images/" + filename1 nrow("Tittle") = tittle ds.Tables("news").Rows.Add(nrow) da.Update(ds, "news") FileUpload1.SaveAs(Server.MapPath("/new/news_images/" & filename1)) lblmsg1.Text = "Image Upload Successful!"
All-Star
182787 Points
23484 Posts
ASPInsiders
Moderator
MVP
Apr 13, 2011 07:17 AM|LINK
Hi,
you first need to upload the image and the use GDI+ to resize it. There are a lot of articles about this: http://www.google.be/#sclient=psy&hl=nl&site=&source=hp&q=asp.net+upload+and+resize&aq=f&aqi=&aql=&oq=&pbx=1&fp=2270f60bc51c5286.
Grz, Kris.
Apr 14, 2011 08:25 AM|LINK
http://www.shotdev.com/aspnet/aspnet-vbnet-image/aspnet-vbnet-upload-and-resize-image/
137 Points
37 Posts
May 03, 2011 06:11 PM|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.
MrJx
Member
219 Points
126 Posts
how to auto resize image then upload ?
Apr 13, 2011 06:46 AM|LINK
how to auto resize image then upload??
any1 can help me?
thanks
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) conn1.Open() rd1 = cmd1.ExecuteReader() rd1.Read() 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 da.Fill(ds, "news") nrow = ds.Tables("news").NewRow() nrow("PicID") = n nrow("ImagePath") = "~/new/news_images/" + filename1 nrow("Tittle") = tittle ds.Tables("news").Rows.Add(nrow) da.Update(ds, "news") FileUpload1.SaveAs(Server.MapPath("/new/news_images/" & filename1)) lblmsg1.Text = "Image Upload Successful!"XIII
All-Star
182787 Points
23484 Posts
ASPInsiders
Moderator
MVP
Re: how to auto resize image then upload ?
Apr 13, 2011 07:17 AM|LINK
Hi,
you first need to upload the image and the use GDI+ to resize it. There are a lot of articles about this: http://www.google.be/#sclient=psy&hl=nl&site=&source=hp&q=asp.net+upload+and+resize&aq=f&aqi=&aql=&oq=&pbx=1&fp=2270f60bc51c5286.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
MrJx
Member
219 Points
126 Posts
Re: how to auto resize image then upload ?
Apr 14, 2011 08:25 AM|LINK
http://www.shotdev.com/aspnet/aspnet-vbnet-image/aspnet-vbnet-upload-and-resize-image/
nathanael.jo...
Member
137 Points
37 Posts
Re: how to auto resize image then upload ?
May 03, 2011 06:11 PM|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.