Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
heyy...
 
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 21:05pm
Comments
Prasad Khandekar at 23-Mar-13 4:57am
   
You won't be able to do that in Pure JavaScript.

1 solution

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

Solution 2

you can use html input type file control instead of asp.net 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);
    }
});
  Permalink  
v3

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

  Print Answers RSS
0 OriginalGriff 381
1 Sergey Alexandrovich Kryukov 265
2 Praneet Nadkar 237
3 Marcin Kozub 225
4 /\jmot 189
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,614
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 23 Mar 2013
Copyright © CodeProject, 1999-2014
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