简体   繁体   中英

Writing data to a local file using HTML5 and Javascript in Chrome

I have created an interactive quiz using html and javascript which will be run on a touchscreen at an event and I need to write the results to a local csv file (so no internet connection). It needs to write to an already existing file, so it cannot be done where the data is stored locally and a download link is generated through the browser.

How would I go about doing this? All methods I have found are either unreliable or no longer supported. The browser I am using is Chrome, so it does not need to be cross-browser compatible.

Can anybody help or point me in the right direction please?

Install a web server.

Point the browser at http://localhost .

Send the data to the server using Ajax or a form submission.

Process the data (including storing it in a file) using the server side language of your choice.

When javascript is used only in the client-side cannot write data as you want.

Follow the @Quentin recommendation about install some web server, as apache using php for instance(It is pretty straight forward!). I also recommend you to create restFull methods to do it with jquery calls from the client side, it is easy to find many examples in the internet and quicky...

If you want something more easy you could work with html post using forms in php, the most easy way to do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM