upload image in ASP.NET
-
hello, i want to allow my users upload image in my site. How can i check that whether the file uploaded by users is an image or not, the dimensions is equal 15px (width = 15px; height = 15px), and the size is less than, for instance 500KB ? Thanks for yr answer.:)
-
hello, i want to allow my users upload image in my site. How can i check that whether the file uploaded by users is an image or not, the dimensions is equal 15px (width = 15px; height = 15px), and the size is less than, for instance 500KB ? Thanks for yr answer.:)
This is a bad way of checking for the file type, but it works! Private Function GetImageFormat(ByVal filepath As String) As System.Drawing.Imaging.ImageFormat Dim ext As String = filepath.Substring(filepath.LastIndexOf(".") + 1) Select Case ext.ToUpper Case "GIF" Return System.Drawing.Imaging.ImageFormat.Gif Case "JPG" Return System.Drawing.Imaging.ImageFormat.Jpeg Case "JPEG" Return System.Drawing.Imaging.ImageFormat.Jpeg Case "BMP" Return System.Drawing.Imaging.ImageFormat.Bmp End Select End Function You can use the following code to check the size of image : Dim myImage As New Bitmap(Server.MapPath(filepath)) If myImage.Width > 100 Then ................................. Endif If myImage.Height > 100 Then ................................. End If :zzz:----------------------------------------------------------------------:(( T Manjaly C# Tutorials and samples : http://www.dotnetspider.com
-
hello, i want to allow my users upload image in my site. How can i check that whether the file uploaded by users is an image or not, the dimensions is equal 15px (width = 15px; height = 15px), and the size is less than, for instance 500KB ? Thanks for yr answer.:)
You do need to upload the image first but then once uploaded you can use the
ImageInfo
class to get all the info on the image you want. It should be faster and richer than loading the uploaded image into thebitmap
class too. regards, Paul Watson Bluegrass South Africa Christopher Duncan quoted: "...that would require my explaining Einstein's Fear of Relatives" Crikey! ain't life grand? Einstein says... -
You do need to upload the image first but then once uploaded you can use the
ImageInfo
class to get all the info on the image you want. It should be faster and richer than loading the uploaded image into thebitmap
class too. regards, Paul Watson Bluegrass South Africa Christopher Duncan quoted: "...that would require my explaining Einstein's Fear of Relatives" Crikey! ain't life grand? Einstein says...