Question

I can write and read files using html5 filesystem. The file is written successfully and then read successfully as well. But i don't know the actual physical path of that. fileEntry.fullPath gieves only \log.txt as path. Can anyone tell where this file is actuall stored in my PC?

If anyone want to check code, here it is:

window.webkitRequestFileSystem(window.TEMPORARY, 1024 * 1024, function(fs) {

  // fs.root is a DirectoryEntry object.
  fs.root.getFile('log.txt', {create: true}, function(fileEntry) {

fileEntry.createWriter(function(writer) {  // writer is a FileWriter object.
console.log(fileEntry);
    writer.onwrite = function(e) { console.log('on write');console.log(e); };
    writer.onerror = function(e) { console.log('on write error');console.log(e);  };

var blob = new Blob(['Hello World!'], {type: 'text/plain'});
    writer.write(blob);

}, opt_errorHandler);

}, opt_errorHandler);
});
Was it helpful?

Solution

When writing data to the local system, web clients (browsers) do not locally store files according to their virtual file names in the script. As the MDN developer guide notes, "It does not necessarily have a relationship to the local file system outside the browser." (Introduction to the File System API)

Therefore, creating a file named "log.txt" in the API does not cause the client to store a real file called "log.txt" on your PC. Google Chrome, for example, will only store a numerically named file (e.g., "00004") in a directory dedicated to sandboxed storage on the client device. The File System API cannot be used to write to the local file system in any way intended for external/outside access to the sandboxed storage area. Also note the to comply with the API spec, client may restrict the types of files that can be stored, such as prohibiting storage of executable code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top