Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>WARNING: <strong>This is compatibility code for very old versions of Safari and Chrome.</strong> Modern browsers all support the FileReader API; here's one tutorial: <a href="https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications</a></p> <p>This code is now only useful if for some reason you have a need to support Safari 5 and older, or Chrome 6 and older.</p> <hr> <p>One possibility is to use <a href="http://playground.justswell.org/drag-and-drop-file-upload.html" rel="nofollow noreferrer">the method used in SwellJS</a>:</p> <p>Use <code>&lt;input type="file" multiple="multiple" /&gt;</code> like so:</p> <pre><code>&lt;form method="post" enctype="multipart/form-data" id="uploadform"&gt; &lt;input type="file" name="dragupload[]" multiple="multiple" onchange="if (this.value) document.getElementById('uploadform').submit();" /&gt; &lt;/form&gt; </code></pre> <p>The input element can be styled to have <code>opacity: 0</code> and positioned (absolutely) over an element that accepts uploads. The entire form can be placed inside an <code>iframe</code> for "pseudo-Ajax" like behavior. And the upload element can be a layer hidden until something is dragged over it.</p> <p>Such an iframe would look like:</p> <pre><code>&lt;script&gt; &lt;!-- var entered = 0; --&gt; &lt;/script&gt; &lt;body ondragenter="entered++;document.getElementById('uploadelement').style.display='block'" ondragleave="entered--;if (!entered) document.getElementById('uploadelement').style.display='none'"&gt; &lt;form method="post" enctype="multipart/form-data" id="uploadform"&gt; Things can be dragged and dropped here! &lt;input type="file" id="uploadelement" name="dragupload[]" multiple="multiple" onchange="if (this.value) { document.getElementById('uploadform').submit(); }" style="display:none;position:absolute;top:0;left:0;right:0;bottom:0;opacity:0;" /&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>This should only be done when Safari or Chrome is detected (since other browsers don't support drag-and-drop onto <code>&lt;input type="file" /&gt;</code> elements), and can be used in combination with the HTML5 <code>drop</code> event for Firefox 3.6+.</p> <p>I can't tell if this is the method Gmail uses, but it certainly works about as well.</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. 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