Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>See <a href="http://jsfiddle.net/5SVuA/1/" rel="nofollow noreferrer"><strong>THIS FIDDLE</strong></a>, the important change is that your logic is wrong- you're checking the height and width against the previously uploaded image (blah), you actually need to execute the upload to check the properties- and then determine what action to take.</p> <p>Note that the below/linked example takes <a href="https://stackoverflow.com/questions/12570834/how-to-preview-image-get-file-size-image-height-and-width-before-upload">this answer on SO</a>, edited for your purposes.</p> <p>HTML</p> <pre><code>&lt;input type="file" id="choose" multiple="multiple" /&gt; &lt;br&gt; &lt;div id="uploadPreview"&gt;&lt;/div&gt; </code></pre> <p>JS</p> <pre><code>function readImage(file) { var reader = new FileReader(); var image = new Image(); var maxh = 800; var maxw = 800; reader.readAsDataURL(file); reader.onload = function (_file) { image.src = _file.target.result; // url.createObjectURL(file); image.onload = function () { var w = this.width, h = this.height, t = file.type, // ext only: // file.type.split('/')[1], n = file.name, s = ~~ (file.size / 1024) + 'KB'; if (w &gt; maxw &amp;&amp; h &gt; maxh) { alert("Height is bigger then over max criteria pls select image max height and width =2024X2024"); alert(width); alert(height); } else { $('#uploadPreview').html('&lt;img src="' + this.src + '"&gt; ' + w + 'x' + h + ' ' + s + ' ' + t + ' ' + n + '&lt;br&gt;'); } }; image.onerror = function () { alert('Invalid file type: ' + file.type); }; }; } $("#choose").change(function (e) { if (this.disabled) return alert('File upload not supported!'); var F = this.files; if (F &amp;&amp; F[0]) for (var i = 0; i &lt; F.length; i++) readImage(F[i]); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload