Note that there are some explanatory texts on larger screens.

plurals
  1. POHow To Set Max Width And Max Height Of Image Before Upload
    primarykey
    data
    text
    <p>I was wondering how can i set max width and max height before the image is uploaded. So when you click on choose file, you select your picture and it loads up so you can see it. Then you crop it then eventually select upload to save it in a directory now my question is how can i set max width and max height before you get a chance to preview it after you select it in when prompt after selecting choose file.</p> <p>Once You Choose Your File If The Image Is Higher Than The Max Height And Max Width Throw a Message and ask them for a smaller picture</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.
    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