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 7830779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:24:27+00:00 2026-06-02T11:24:27+00:00

I loaded a directory using file input and webkitdirectory as mentioned below. <input id=file_input

  • 0

I loaded a directory using file input and webkitdirectory as mentioned below.

<input  id="file_input"  type="file" webkitdirectory directory  />

After directory selected I can read file size and other information. My question is how to read this directory using DirectoryReader interface.

I tried with below code, but not success. results.length becomes zero. Am I missing anything?

window.requestFileSystem(TEMPORARY, 1024*1024 /*1MB*/, function(fs) {
        var dirReader = fs.root.createReader();
        var entries = [];
        // Call the reader.readEntries() until no more results are returned.
        var readEntries = function() {
            dirReader.readEntries(function(results) {
                // If no more results are returned, we're done.
                if (!results.length) {
                    // Sort list by name of entry.
                    entries.sort(function(a, b) {
                        return a.name < b.name ? -1 :
                        b.name < a.name ? 1 : 0;
                    });
                   // listResults(entries); // Render the list.
                } else {
                    // Add in these results to the current list.
                    entries = entries.concat(toArray(results));
                    readEntries();
                }
            }, errorHandler);
        };
        readEntries(); // Start reading the directory.
    }, errorHandler);

Any help is appreciated.

  • 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-02T11:24:29+00:00Added an answer on June 2, 2026 at 11:24 am

    To read the content of a directory :

    fs.root.getDirectory('Documents', {}, function(dirEntry){
      var dirReader = dirEntry.createReader();
      dirReader.readEntries(function(entries) {
        for(var i = 0; i < entries.length; i++) {
          var entry = entries[i];
          if (entry.isDirectory){
            console.log('Directory: ' + entry.fullPath);
          }
          else if (entry.isFile){
            console.log('File: ' + entry.fullPath);
          }
        }
    
      }, errorHandler);
    }, errorHandler);
    

    In the code above, the isDirectory and isFile properties are used in order to obtain a different output for directories and files, respectively. Additionally, we use the fullPath property in order to get the full path of the entry, instead of its name only.

    From : http://net.tutsplus.com/tutorials/html-css-techniques/toying-with-the-html5-filesystem-api/

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

Sidebar

Related Questions

I can load the fixture file in my django application by using loaddata: manage.py
I loaded a custom DataTable into an UltraChart of type GanttChart . The data
I loaded a 640 x 480 (in px) jpg image from res using Bitmap.
I loaded an UIView out of a nib-file. I wrote some methods which I
how is this solution I am using now: I have a 1MB .dbf file
I have the following file Log4net.config in my bin directory: <?xml version=1.0 encoding=utf-8 ?>
I'm creating a collage of thumbnails using Ruby 1.9.3. The thumbnails are being loaded
I am using the following code in my htaccess file RewriteEngine On RewriteCond %{HTTP_HOST}
so evidently according to this Using relative URL in CSS file, what location is
I'm using Ant 1.8, JUnit 4.8.2. I'm trying to load a properties file and

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.