0

The problem is, i want to save a text file (or anything) in the local system using javascript.

shahalpk
  • 3,383
  • 7
  • 36
  • 55

2 Answers2

1

There is no practical real world way to create a local file. However if you want to to just store data locally then try these two methods.

The old way:

http://www.w3schools.com/js/js_cookies.asp

The new way:

http://diveintohtml5.ep.io/storage.html

Alternatively, you could create a file with php and serve it out to the user.

DanBeale
  • 310
  • 4
  • 15
Caimen
  • 2,623
  • 2
  • 26
  • 43
1

You can't write to the user's file system. But you initiate a file download that the user can then save wherever they'd like.

In PHP, you can just use

header('Content-Disposition: attachment; filename=file.txt'); 
echo('File contents');
Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217