Click here to Skip to main content
13,097,012 members (81,582 online)
Rate this:
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
Updated 19-Jan-17 2:06am
Prasad Khandekar 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 19 Jan 2017
Copyright © CodeProject, 1999-2017
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