I'm trying to write to a local file using javascript and html on a mac. I've seen forums saying you could use ActiveXObject, but that is only on windows using IE right?
4 Answers
You can not access local file system using Javascript. But if want to store a Javascript variable, then you can look into LocalStorage.

- 4,223
- 2
- 16
- 24
If HTML5 is a valid option for you, you can use the new filesystem API. Take a look at this introduction: http://www.noupe.com/webdev/html5-filesystem-api-create-files-store-locally-using-javascript-webkit.html

- 11,492
- 14
- 59
- 94
Security limitations don't allow javascript to access the local file system through the browser. But you can use the Node.js interpreter to run javascript "server side". If this is the case, your code should look something like this.

- 1
- 1

- 1,586
- 1
- 15
- 30
yes ,there is a way to save file,but not in local system,because of some security reasons browser's don't allow to save local files,but there are many ways by that you can save file in client side system!
The most common if you using HTML5 then localstorage.setItem('yourfilename',fileasblob)
;
Create a blob of file that you want to store,and save it on localstorage
by its name!
example :
var filedata = "......yourfilecontent.....";
var locfile = new Blob([filedata],{content-type});
localstorage.setItem('newfile.txt',locfile); //for save
var mylocfile = localstorage.getItem('newfile.txt');
var locfilesrc = URL.createObjectURL(mylocfile);//retrive as temporary URL for any use!
by this way you can save any file on local storage,And the main thing is that this storage is not deleted until you can not clear it by your own!

- 1,401
- 16
- 33