-2

Please anyone tell me how to create a .txt file from client side using javascript or jquery.

I am doing a project currently for one survey purpose in an exhibition. We are going to use an android tablet to conduct the survey. There will be chance to lost the internet connection in between. At that time if a user submits the form the data will be lost. So my plan is to store the data submitted by the user before submitting as a text file using javascript or something like that.

Please suggest some idea.

Zulu
  • 8,765
  • 9
  • 49
  • 56
prasanth prem
  • 454
  • 3
  • 13
  • 3
    I suggest to use LocalStorage for storing data on client side. – Adam Szabo Oct 11 '15 at 11:44
  • I agree with Adam by using localStorage – TJL Oct 11 '15 at 11:45
  • You can create a text file by creating a blob and "downloading" it. see https://github.com/eligrey/FileSaver.js/ for a simple library. Note: This requires user interaction, and I'm not 100% sure it will work on an android device – Jaromanda X Oct 11 '15 at 11:48

1 Answers1

-1

The browser prevents sites to mess with the file system, so you can't create an txt file using client-side Javascript. Instead you can store the form data in localStorage.

someone235
  • 567
  • 2
  • 7
  • 21