Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8225093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:17:55+00:00 2026-06-07T15:17:55+00:00

hello i am trying to drag and drop files into my filesystem using chrome,

  • 0

hello i am trying to drag and drop files into my filesystem using chrome, but i get the following error in the console:

var dnd = new DnDFileController('body', function(files, e) {
    var items = e.dataTransfer.items;
    for (var i = 0, item; item = items[i]; ++i) {
      traverseFileTree(item.webkitGetAsEntry());
**Uncaught TypeError: Object #<DataTransferItem> has no method 'webkitGetAsEntry'**
    }
  });

i also tried to add the method in the loop like this:

for (var i = 0, item; item = items[i].webkitGetAsEntry();; ++i) {
      traverseFileTree(item);
    }

the error is like this:

Uncaught TypeError: Object #<DataTransferItem> has no method 'webkitGetAsEntry' app.js:513
(anonymous function) app.js:513
DnDFileController.drop dnd.js:27

the DNDFileController.drop code is the following:

this.drop = function(e) {
    e.stopPropagation();
    e.preventDefault();

    el_.classList.remove('dropping');

    onDropCallback(e.dataTransfer.files, e);
  };

but i get the same error, any ideas? thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:17:56+00:00Added an answer on June 7, 2026 at 3:17 pm

    Presumably you’re using this DnDFileController – http://html5-demos.appspot.com/static/filesystem/filer.js/demos/js/dnd.js . So first off, I’ve got your code to a testable state as:

    function DnDFileController(selector, onDropCallback) {
      var el_ = document.querySelector(selector);
    
      this.dragenter = function(e) {
        e.stopPropagation();
        e.preventDefault();
        el_.classList.add('dropping');
      };
    
      this.dragover = function(e) {
        e.stopPropagation();
        e.preventDefault();
      };
    
      this.dragleave = function(e) {
        e.stopPropagation();
        e.preventDefault();
        //el_.classList.remove('dropping');
      };
    
      this.drop = function(e) {
        e.stopPropagation();
        e.preventDefault();
    
        el_.classList.remove('dropping');
        onDropCallback(e.dataTransfer.files, e);
      };
    
      el_.addEventListener('dragenter', this.dragenter, false);
      el_.addEventListener('dragover', this.dragover, false);
      el_.addEventListener('dragleave', this.dragleave, false);
      el_.addEventListener('drop', this.drop, false);
    };
    
    var dnd = new DnDFileController('body', function(files, e) {
        var items = e.dataTransfer.items;
        for (var i = 0, item; item = items[i]; ++i) {
          if (item.kind == 'file') {
              debugger
              console.log(item.webkitGetAsEntry());
          }
        }
      });
    

    Now, checking the state of item in the debugger, in Chrome 20.0.1132.27 beta, it is only exposing those properties and methods which are in the current spec[1] – ie, item.kind, item.type, item.getAsString(callback), and item.getAsFile(). DataTransferItem.webkitGetAsEntry() is not exposed. As far as I can tell[2], Chrome wasn’t supposed to be exposing their proposed webkitGetAsEntry yet, and after having it turned on for just one week[3], they turned its switch back off. So at the moment, it isn’t enabled unless you use whatever flags to enable it[4].

    Once you enable it, it also looks like its intended, like getAsString, to be used with a callback, not just as a getter. See example in [5]:

        var items = e.dataTransfer.items;
        for (var i = 0; i < items.length; ++i) {
          if (items[i].kind == 'file') {
              items[i].webkitGetAsEntry(function(entry) {
              displayEntry(entry.name + (entry.isDirectory ? ' [dir]' : ''));
              ...
            });
          }
        }
    

    Note that they also are wrapping it in a protective check that file[i] is actually a file; this is in my test code above, but missing in your code.

    But if you’re just trying to access the files, is there a reason you want to use this experimental method? It’s a pretty simple loop to use a FileReader to read the file, then Blob-ify it, then store it in a local FileSystem… and all those methods are far less experimental and new.

    Refs:

    [1] http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#the-datatransferitem-interface

    [2] http://trac.webkit.org/changeset/118507

    [3] http://code.google.com/p/chromium/issues/detail?id=129702

    [4] https://bugs.webkit.org/show_bug.cgi?id=87457

    [5] http://lists.w3.org/Archives/Public/public-whatwg-archive/2012Apr/0078.html

    ======================================================

    UPDATE 7/26/2012:

    This method has now had the flags requirement removed, and is available for general use with the release of Chrome 21 on 7/23/12. However, for the use case described here, the above is much simpler to implement, and better fits the needs, as there was no need to also be able to read entire directories at the same time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started trying to implement drag-and-drop of virtual files (from a C# 4/WPF app)
Hello I am trying to make a C# program that downloads files but I
Hello I am trying to create a stacked barplot using the following code: test
Hello there im trying to send files using client-server classes in java. For some
Hello trying to get my website to display correctly having trouble. I am using
Hello i been trying to get a tokenizer to work using the boost library
Hello I am trying to get the efficiency for Strassen's algorithm but need some
Hello im trying to echo only the 50 letters, but something in my code
hello i am trying a sqlite database tutorial to build, but its not working
hello i am trying to load a list of filenames from a folder into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.