JavaScript jQuery drag and drop image to textarea handle event jquery drag drop file upload,jquery drag drop list,jquery

To handle drop event on your area (text area or div) you need to do this:

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
};

Next you need to send this files to server and show it in the browser if you want.

function readfiles(files) {
var formData = new FormData(); // we initialise a new form that will be send to php 

for (var i = 0; i < 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 for testing path_to_file_handler.php

<?php 
  print_r($_POST);
  print_r($_FILES); 
?>

Hope it will help somebody.

Answer:1

How to call an swipe event?. I want to trigger an event in swipe. The below code is works fine in normal query event. don't know how to achieve in meteor event. $('.your-class').on('swipe', ...

How to call an swipe event?. I want to trigger an event in swipe. The below code is works fine in normal query event. don't know how to achieve in meteor event. $('.your-class').on('swipe', ...

I understand it for binary, but I'm not comprehending it for hex. Here's some examples: Number(0.15).toString(16) // 0.26666666666666 Number(1.5).toString(16) // 1.8 Number(.18).toString(16) // 0....

I understand it for binary, but I'm not comprehending it for hex. Here's some examples: Number(0.15).toString(16) // 0.26666666666666 Number(1.5).toString(16) // 1.8 Number(.18).toString(16) // 0....

I have 3 textarea elements on my page and there could be more than 3 in the future. I want to get all the text from these textarea fields. If I do $('textarea').val(); in chrome console, it only ...

I have 3 textarea elements on my page and there could be more than 3 in the future. I want to get all the text from these textarea fields. If I do $('textarea').val(); in chrome console, it only ...

  1. spam texts from multiple numbers
  2. combine texts from multiple cells
  3. multiple texts from different numbers
  4. texts multiple choice questions
  5. texts multiple choice
  6. multiple texts from unknown numbers
  7. multiple texts from iphone
  8. multiple texts from uber

Sol let's suppose that we send a post query to a PHP file, this query where we have ...&title=title where title is for example title=$(#title).val(); (assuming we're including Jquery) in PHP we ...

Sol let's suppose that we send a post query to a PHP file, this query where we have ...&title=title where title is for example title=$(#title).val(); (assuming we're including Jquery) in PHP we ...

  1. how does browser interpret javascript