Unfortunately, you cannot determine the dimensions of a file at the client side (well, you can't without parsing the byte array into the image file format manually - and that's probably not what you're after). What you could do (assuming you're using HTML 5), is post the file over to the server using AJAX and the File API, and have the file decode there.
One trick you could use, and this is something I talked about as a way of handling another problem,
yesterday[
^] is to use an
HttpHandler
to do the checking for you. Basically, you would post the image as byte data across to the
HttpHandler
which would decode the image into a physical image and test it in a similar way to Krunal Rohit's code, and then return an appropriate value if it can be uploaded properly.
The downside of this approach, of course, is that you are posting the data to the server twice, but there are techniques you could use to mitigate that (such as storing the uploaded image in the
Session
object).