Click here to Skip to main content
11,640,125 members (69,249 online)
Rate this: bad
Please Sign up or sign in to vote.

Is there is javascript or jquery for validate the width and height of image before uploading using fileupload control in .aspx..

I searched through internet ..I got server side validation but I didn't get javascript or jquery for this....
Posted 22-Mar-13 20:05pm
Prasad Khandekar at 23-Mar-13 4:57am
You won't be able to do that in Pure JavaScript.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

you can use html input type file control instead of image control and follow up jquery which might help you but remember it might not work on all browsers but on ff and chrome it works like a charm.
<input type="file" name="photo" id="photoInput" />
var _URL = window.URL;
$("#photoInput").change(function (e) {
    var file, img;
    if ((file = this.files[0])) {
        img = new Image();
        img.onload = function () {
            alert("Width:" + this.width + "   Height: " + this.height);//this will give you image width and height and you can easily validate here....
        img.src = _URL.createObjectURL(file);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Suvendu Shekhar Giri 225
1 F-ES Sitecore 170
2 CPallini 167
3 Sergey Alexandrovich Kryukov 144
4 himanshu agarwal 142
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,847
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,650
4 F-ES Sitecore 2,558

Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 23 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100