Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Q2</strong> use canvas.toBlob instead of canvas.mozGetAsFile. <a href="https://github.com/blueimp/JavaScript-Canvas-to-Blob" rel="nofollow">There is a polyfill to increase browser compatibility.</a> </p> <p>Usage as show in their page</p> <pre><code>var canvas = document.createElement('canvas'); canvas.toBlob( function (blob) { // the blob is the jpeg file var formData = new FormData(); formData.append('file', blob, fileName); /* ... */ }, 'image/jpeg' ); </code></pre> <p><strong>Q4</strong> specify <code>canvas.toBlob(callback, 'image/jpeg', quality)</code> where quality is from 0.0 to 1.0 (highest quality)</p> <p><strong>Q3</strong> you can have multiple buttons in a form.</p> <pre><code>&lt;form&gt; &lt;input id="file" type="file" name="file" multiple/&gt;&lt;br/&gt; &lt;input id="confirm" type="checkbox" name="confirm"&gt;confirm&lt;/input&gt;&lt;br/&gt; ... &lt;input name="upload" value="Upload" type="button"/&gt; &lt;input name="upload-resize" value="Upload and resize" type="button"/&gt; &lt;/form&gt; </code></pre> <p>Note that the form tag doesn't contain the onsubmit attribute and the input type is now button instead of submit.</p> <pre><code> &lt;input name="upload" value="Upload" type="button" onclick="myfunction()"/&gt; </code></pre> <p>or instead of onclick attribute, you can use addEventListener, etc.</p> <p><strong>Q1</strong> You shoudn't go back in the history. Your location.reload() is correct but it must be done after the send/upload is completed.</p> <pre><code>xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return; } location.reload(); } </code></pre> <p><a href="http://ajaxpatterns.org/XMLHttpRequest_Call" rel="nofollow">XMLHttpRequest</a> is asynchronous so the send method returns even before the upload has completed! To know if the send has finished, use onreadystatechange as shown above.</p> <p>Note: you may want to check the response status code too.</p>
    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.
    1. 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