-4

I have a html form and I want to save its data in a text file. I used ActiveX object concept and it is working on IE.I want the same code to work on chrome and Firefox also. How to do that ??

1 Answers1

2

Browsers don't have access to local file system do to security reasons.

You can use ajax to post the form to the server, save the data to a temp file, and return url that points to the file. When browser receive the ajax response containing the file url, redirect browser to the url. Browser will download the file after.

For ajax you can use jQuery http://api.jquery.com/jquery.ajax/ To use ajax to post form take a look at this answer jQuery Ajax POST example with PHP

To redirect browser from the client you can write for example window.location.href = 'myurl.com/foo/bar'

Community
  • 1
  • 1
milan
  • 133
  • 6