files/en-us/web/api/filesystementry/copyto/index.md
{{APIRef("File and Directory Entries API")}}{{Deprecated_Header}}{{Non-standard_Header}}
The {{domxref("FileSystemEntry")}} interface's method
copyTo() copies the file
specified by the entry to a new location on the file system.
There are some typical restrictions on what you can do:
copyTo(newParent)
copyTo(newParent, newName)
copyTo(newParent, newName, successCallback)
copyTo(newParent, newName, successCallback, errorCallback)
newParent
newName {{optional_inline}}
successCallback {{optional_inline}}
errorCallback {{optional_inline}}
None ({{jsxref("undefined")}}).
DOMException.INVALID_MODIFICATION_ERR
DOMException.QUOTA_EXCEEDED_ERR
This example shows how a temporary log file might be moved into a more permanent "log" directory.
workingDirectory.getFile(
"tmp/log.txt",
{},
(fileEntry) => {
workingDirectory.getDirectory(
"log",
{},
(dirEntry) => {
fileEntry.copyTo(dirEntry);
},
handleError,
);
},
handleError,
);
{{Compat}}