1 Replies - 266 Views - Last Post: 27 June 2019 - 07:20 AM

#1 sina9386   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-June 19

Drop an object from another browser window into a div and download it.

Posted 27 June 2019 - 01:15 AM

Hi I am trying to drop an object from another browser window into my div area and download the same to my local system. It works for local files- i am able to drop a file existing from my local drive and download it. However i would like to handle any object from a browser window to be dropped and then download. I dont know if i miss something as i dont get the object type upon dropping. My code for dropping:
var dropZone = document.getElementById('divdropZone');
dropZone.addEventListener('drop', function (e) {
        e.stopPropagation();
        e.preventDefault();
        var files = e.dataTransfer.files; 

        for (var i = 0, file; file = files[i]; i++) {
                hrefsrc = file.name;
                 var reader = new FileReader();

                reader.onload = function (e2) {

                    // finished reading file data.
                    droppedFile = e2.target.result; // stores the dropped file for downloading
                }

                // start reading the file data.
                 reader.readAsDataURL(file);
                
            
        }
    });




Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Drop an object from another browser window into a div and download it.

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15109
  • View blog
  • Posts: 60,436
  • Joined: 12-June 08

Re: Drop an object from another browser window into a div and download it.

Posted 27 June 2019 - 07:20 AM

Quote

handle any object from a browser window

What do you mean 'object'?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1