FileSystemEntry

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The FileSystemEntry interface of the File and Directory Entries API represents a single in a file system. The entry can be a file or a directory (directories are represented by the DirectoryEntry interface). It includes methods for working with files—including copying, moving, removing, and reading files—as well as information about a file it points to—including the file name and its path from the root to the entry.

Because this is a non-standard API, whose specification is not currently on a standards track, it's important to keep in mind that not all browsers implement it, and those that do may implement only small portions of it. Check the Browser compatibility section for details.

Basic concepts

You don't create FileSystemEntry objects directly. Instead, you will receive an object based on this interface through other APIs. This interface serves as a base class for the FileSystemFileEntry and FileSystemDirectoryEntry interfaces, which provide features specific to file system entries representing files and directories, respectively.

The FileSystemEntry interface includes methods that you would expect for manipulating files and directories, but it also includes a convenient method for obtaining the URL of the entry: toURL(). It also introduces a new URL scheme: filesystem:.

You can use the filesystem: scheme on Google Chrome to see all the files and folders that are stored in the origin of your app. Just use filesystem: scheme for the root directory of the origin of the app. For example, if your app is in http://www.html5rocks.com, open filesystem:http://www.html5rocks.com/temporary/ in a tab. Chrome shows a read-only list of all the files and folders stored the origin of your app.

Example

To see an example of how toURL() works, see the method description. The snippet below shows you how you can remove a file by name.

// Taking care of the browser-specific prefixes.
window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem; 

...

// Opening a file system with temporary storage
window.requestFileSystem(TEMPORARY, 1024*1024 /*1MB*/, function(fs) {
  fs.root.getFile('log.txt', {}, function(fileEntry) {
    
    fileEntry.remove(function() {
      console.log('File removed.');
    }, onError);
  
  }, onError);
}, onError); 

Properties

This interface provides the following properties.

filesystem Read only
A FileSystem object representing the file system in which the entry is located.
fullPath Read only
A USVString object which provides the full, absolute path from the file system's root to the entry; it can also be thought of as a path which is relative to the root directory, prepended with a "/" character.
isDirectory Read only
A Boolean which is true if the entry represents a directory; otherwise, it's false.
isFile Read only
A Boolean which is true if the entry represents a file. If it's not a file, this value is false.
name Read only
A USVString containing the name of the entry (the final part of the path, after the last "/" character).

Methods

This interface defines the following methods.

copyTo()
Copies the file or directory to a new location on the file system.
getMetadata()
Obtains metadata about the file, such as its modification date and size.
getParent()
Returns a FileSystemDirectoryEntry representing the entry's parent directory.
moveTo()
Moves the file or directory to a new location on the file system, or renames the file or directory.
remove()
Removes the specified file or directory. You can only remove directories which are empty.
toURL()
Creates and returns a URL which identifies the entry. This URL uses the URL scheme "filesystem:".

Specifications

Specification Status Comment
File and Directory Entries API Draft Draft of proposed API

This API has no official W3C or WHATWG specification.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
ExperimentalNon-standard
Chrome Full support 13
Prefixed
Full support 13
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge No support No
Notes
No support No
Notes
Notes Edge implements this interface as part of the non-standard WebKitEntry interface, which also implements interfaces FileSystemFileEntry and FileSystemDirectoryEntry.
Firefox Full support 50IE No support NoOpera No support NoSafari No support NoWebView Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 50Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
filesystem
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox Full support 50IE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
fullPath
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox Full support 50IE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
isDirectory
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox Full support 50IE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
isFile
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox Full support 50IE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
name
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox Full support 50IE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
copyTo
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android ?
getMetadata
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android ?
getParent
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android ?
moveTo
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android ?
remove
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android ?
toURL
ExperimentalNon-standard
Chrome Full support 13Edge ? Firefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

See also

Document Tags and Contributors

Last updated by: fscholz,