This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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's method getParent() obtains a FileSystemDirectoryEntry.


FileSystemEntry.getParent(successCallback[, errorCallback]);


A function which is called when the parent directory entry has been retrieved. The callback receives a single input parameter: a FileSystemDirectoryEntry object representing the parent directory. The parent of the root directory is considered to be the root directory, itself, so be sure to watch for that.
errorCallback Optional
An optional callback which is executed if an error occurs. There's a single parameter: a FileError describing what went wrong.

Return value



The operation failed because the file system's state doesn't permit it. This can happen, for example, if the file system's cached state differs from the actual state of the file system.
The specified path could not be found.
Security restrictions prohibit obtaining the parent directory's information.


This example renames  the file specified by the variable fileEntry to "newname.html".

fileEntry.getParent(function(parent) {
  fileEntry.moveTo(parent, "newname.html", function(updatedEntry) {
    console.log("File " + + " renamed to newname.html.");
}, function(error) {
  console.error("An error occurred: Unable to rename " +
        + " to newname.html.");

This is accomplished by first obtaining a FileSystemDirectoryEntry object representing the directory the file is currently located in. Then moveTo() is used to rename the file within that directory.

Using promises

Currently, there isn't a Promise-based version of this method. You can, however, create a simple helper function to adapt it, like this:

function getParentPromise(entry) {
  return new Promise((resolve, reject) => {
    entry.getParent(resolve, reject);

A similar approach can be taken elsewhere in the File and Directory Entries API.


Specification Status Comment
File and Directory Entries API
The definition of 'getParent()' in that specification.
Editor's Draft Initial specification.

This API has no official W3C or WHATWG specification.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 13 webkit No support No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support No support 0.16webkit No support No support No support No support

See also

Document Tags and Contributors

Contributors to this page: Sheppy
Last updated by: Sheppy,