2

Hi I am trying to write the text file using HTML using below code..

function onInitFs(fs) {
     fs.root.getFile('paths.txt', { create: true }, function (fileEntry) {
        fileEntry.createWriter(function (fileWriter) {                            
                        fileWriter.onwriteend = function (e) {
                            alert('Paths are Stored :-)');
                        };
                        fileWriter.onerror = function (e) {
                            alert('Write failed: ' + e.toString());
                        };
                        var bb = new (window.BlobBuilder || window.WebKitBlobBuilder)();
                        bb.append($.stringify(options));                            
                        fileWriter.write(bb.getBlob('text/plain'));
          }, errorHandler);
     }, errorHandler);

  }

But as per my knowledge it is storing in the Temporary memory. But I just want to put the file in the same folder where this function is placed(HTML5). For example if I am running a file from a domain Project/html/. When I call that function it should write the text file in same directory.

Please let me know whether it is possible or not?

2 Answers 2

1

I guess you are aware of that the FileWriter API is still only supported by Chrome, so its pretty much a nono in any serious app. However, did you call webkitStorageInfo.requestQuota() with the PERSISTENT flag ?

That is required to have files keep stored. Afaik, Chrome will never really write files down to disk. It's pretty much a sandbox environment, like an own little database which fakes a filesystem.

But that knowledge only comes from my own little experiments, someone will correct me if I'm wrong.

Sign up to request clarification or add additional context in comments.

1 Comment

Any way to achieve this using Ajax?
0

This article explains the use of the PERSISTENT flag and requesting quotas in more depth: http://www.html5rocks.com/en/tutorials/file/filesystem/

But FileWriter is only a draft so far, it's in Firefox's roadmap but there's no definite date for it: https://wiki.mozilla.org/Features/Platform/FileWriter

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.