Click here to Skip to main content
15,356,336 members
Please Sign up or sign in to vote.
4.00/5 (1 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....
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

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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900