Note that there are some explanatory texts on larger screens.

plurals
  1. POMax Height And Max Width Validtation Before Jquery Upload Preview
    primarykey
    data
    text
    <p>Ok so I'm trying to do a max height max width validation before jquery upload preview so that if the image is larger than the max height or max width to alert user and ask them to choose a smaller photo. How would i be able to do that part of code?</p> <p>html code:</p> <pre><code>&lt;img id="uploadPreview" style="display:none;"/&gt; &lt;!-- image uploading form --&gt; &lt;form action="upload.php" method="post" enctype="multipart/form-data"&gt; &lt;input id="uploadImage" type="file" accept="image/jpeg" name="image" /&gt; &lt;input type="submit" value="Upload"&gt; &lt;!-- hidden inputs --&gt; &lt;input type="hidden" id="x" name="x" /&gt; &lt;input type="hidden" id="y" name="y" /&gt; &lt;input type="hidden" id="w" name="w" /&gt; &lt;input type="hidden" id="h" name="h" /&gt; &lt;/form&gt; </code></pre> <p>jquery code:</p> <pre><code>function setInfo(i, e) { $('#x').val(e.x1); $('#y').val(e.y1); $('#w').val(e.width); $('#h').val(e.height); } $(document).ready(function() { var p = $("#uploadPreview"); // prepare instant preview $("#uploadImage").change(function(){ // fadeOut or hide preview p.fadeOut(); // prepare HTML5 FileReader var oFReader = new FileReader(); oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]); oFReader.onload = function (oFREvent) { p.attr('src', oFREvent.target.result).fadeIn(); }; }); // implement imgAreaSelect plug in (http://odyniec.net/projects/imgareaselect/) $('img#uploadPreview').imgAreaSelect({ // set crop ratio (optional) aspectRatio: '1:1', onSelectEnd: setInfo }); }); </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. 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