Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To handle drop event on your area (text area or div) you need to do this:</p> <pre><code>var dropzone = document.getElementById('ta'); // paste your dropzone id here dropzone.ondrop = function(e){ console.log('drop'); // for debugging reasons e.preventDefault(); // stop default behaviour readfiles(e.dataTransfer.files); // function to handle file(s) that was added to dropzone }; </code></pre> <p>Next you need to send this files to server and show it in the browser if you want. </p> <pre><code>function readfiles(files) { var formData = new FormData(); // we initialise a new form that will be send to php for (var i = 0; i &lt; files.length; i++) { // if we have more that one file previewImg(files[i]); // function to preview images formData.append('file'+i, files[i]); } formData.append('moreInfo','myValuableValue');// you can append additional string info $.ajax({ url: './path_to_file_handler.php', type: 'POST', data: formData, async: true, success: function (data) { console.log(data); }, cache: false, contentType: false, processData: false }); } function previewImg(file) { var reader = new FileReader(); reader.onload = function (event) { var image = new Image(); image.src = event.target.result; // set image source image.width = 550; // a fake resize document.getElementById('body').appendChild(image); // append image to body }; reader.readAsDataURL(file); } </code></pre> <p>Code for testing path_to_file_handler.php</p> <pre><code>&lt;?php print_r($_POST); print_r($_FILES); ?&gt; </code></pre> <p>Hope it will help somebody.</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.
    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