1

I would like to know if exists any form to let AngularJS read, create or write into a file (could be a txt file or a json file).

And obviously delete this file just when i want. (don't let the browser delete or angular delete it)

Can anybody give and advise, how start?

julioVG
  • 81
  • 1
  • 12
  • 2
    This isn't really an Angular problem, more a JavaScript one. See answer here http://stackoverflow.com/questions/371875/local-file-access-with-javascript – cortexlock Apr 20 '15 at 10:53
  • i find those links: http://www.html5rocks.com/es/tutorials/file/filesystem/ and http://www.w3.org/TR/file-system-api/ but i don't know if all browser can be supported. Also the problem for me, is thinking to get information on my local device. Thanks – julioVG Apr 20 '15 at 10:54
  • It should answer your question then...JS runs in a browser sandbox to stop malicious code from accessing the file system. You can do it using File APIs as described in that link, but only Chrome supports them and the standard is going to be deprecated. NodeJS can open and write to files, so you can try that depending upon exactly what you're trying to do. – cortexlock Apr 20 '15 at 10:58
  • yes i read that with NodeJs is possible do that too, but the point is that i want create a small hybrid app, and package with phonegap, and when the final user want let all the information that he/she generate locally to the server. i want that my app works without internet connection. what options i have ? Thanks – julioVG Apr 20 '15 at 11:01
  • Your post said Angular, and that you want to write to the filesystem. It wasn't clear that you are developing a mobile app. Look into window.localStorage and Cordova / Phonegap File API. – cortexlock Apr 20 '15 at 11:03
  • i put Angular because i work a lot with it, and i think that this framwork has this option. but now i see that i have think that javascript and html5 has this options. Another point, i don't want use localStorage, because it could be deleted when you refresh the app, is for that reasson that i'm looking for others options. – julioVG Apr 20 '15 at 11:07

1 Answers1

0

Writing and read has nothing to do with AngularJS. Java script comes with File read and write capability. js-xlsx is a useful file parser which you can use.

https://github.com/SheetJS/js-xlsx

Aakash
  • 1,751
  • 1
  • 14
  • 21
  • i find those links: http://www.html5rocks.com/es/tutorials/file/filesystem/ and http://www.w3.org/TR/file-system-api/ but i don't know if all browser can be supported. Also the problem for me, is thinking to get information on my local device. Thanks – julioVG Apr 20 '15 at 10:55