<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input type="file" name="file" id="file"> <br/> <br/> Width: <span id='width'></span><br/> Height: <span id='height'></span> <script> var _URL = window.URL || window.webkitURL; $("#file").change(function (e) { var file, img; if ((file = this.files[0])) { img = new Image(); img.onload = function () { var width=this.width; var height=this.height; $("#width").html(width); $("#height").html(height); if(width > 200 || height > 200) { alert("Width and heigth should not be more than 200px "); } }; img.src = _URL.createObjectURL(file); } }); </script>