Click here to Skip to main content
11,496,146 members (435 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.

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
Prasad Khandekar at 23-Mar-13 4:57am
You won't be able to do that in Pure JavaScript.

1 solution

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 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web03 | 2.8.150520.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