Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. upload image in ASP.NET

upload image in ASP.NET

Scheduled Pinned Locked Moved ASP.NET
questioncsharpcssasp-net
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MrMicrosoftvn
    wrote on last edited by
    #1

    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.:)

    T P 2 Replies Last reply
    0
    • M MrMicrosoftvn

      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.:)

      T Offline
      T Offline
      T Manjaly
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • M MrMicrosoftvn

        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.:)

        P Offline
        P Offline
        Paul Watson
        wrote on last edited by
        #3

        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 the bitmap 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...

        A 1 Reply Last reply
        0
        • P Paul Watson

          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 the bitmap 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...

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          i can not find the ImageInfo class !!!:(:(

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups