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. Image upload dimensions

Image upload dimensions

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadminquestion
5 Posts 3 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.
  • P Offline
    P Offline
    Paul McGann
    wrote on last edited by
    #1

    I'm trying to validate an image before uploading to the server. Basically I want to validate the image width and height before uploading. I have seen this done before using javascript but thought maybe someone would have another solution?

    ASP all the way

    J L 2 Replies Last reply
    0
    • P Paul McGann

      I'm trying to validate an image before uploading to the server. Basically I want to validate the image width and height before uploading. I have seen this done before using javascript but thought maybe someone would have another solution?

      ASP all the way

      J Offline
      J Offline
      JHizzle
      wrote on last edited by
      #2

      Well if you want it done prior to uploading then I'm afraid that javascript is your only method. Can't access a file server side without it being there after all. Of course people disabling javascript would get around this so, you should really have a redundant check on the server side anyway.

      P 1 Reply Last reply
      0
      • P Paul McGann

        I'm trying to validate an image before uploading to the server. Basically I want to validate the image width and height before uploading. I have seen this done before using javascript but thought maybe someone would have another solution?

        ASP all the way

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        In Asp.NET you can check image file's height and width before uploading it using following code.

        Dim upBmp As Bitmap = Bitmap.FromStream(FileUpload1.PostedFile.InputStream)
        Dim upWidth As Integer = upBmp.Width
        Dim upHeight As Integer = upBmp.Height

        But for that you need server trip. So best way is using javascript. HTH

        Jinal Desai - LIVE Experience is mother of sage....

        P 1 Reply Last reply
        0
        • J JHizzle

          Well if you want it done prior to uploading then I'm afraid that javascript is your only method. Can't access a file server side without it being there after all. Of course people disabling javascript would get around this so, you should really have a redundant check on the server side anyway.

          P Offline
          P Offline
          Paul McGann
          wrote on last edited by
          #4

          thanks i see the problem. thanks for the advice tho.

          ASP all the way

          1 Reply Last reply
          0
          • L Lost User

            In Asp.NET you can check image file's height and width before uploading it using following code.

            Dim upBmp As Bitmap = Bitmap.FromStream(FileUpload1.PostedFile.InputStream)
            Dim upWidth As Integer = upBmp.Width
            Dim upHeight As Integer = upBmp.Height

            But for that you need server trip. So best way is using javascript. HTH

            Jinal Desai - LIVE Experience is mother of sage....

            P Offline
            P Offline
            Paul McGann
            wrote on last edited by
            #5

            I'll try this method and see if it works for my scenario. thanks

            ASP all the way

            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