Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to download client side content

I want to let the user download the current content of a textarea into a text file on their computer. In the past I would create an iframe pointing to a URL with the data, which would trigger a file download dialog. However this time the data is client side.

So, is it possible to let the user download data without sending it server side?

like image 979
hoju Avatar asked Nov 23 '25 15:11

hoju


1 Answers

If it does not need to work in "old browsers" like IE, you could open a new window with the location 'data:text/plain,' + yourTextarea.value. The user can then save that file using the File/Page menu or Ctrl+S.

like image 131
janmoesen Avatar answered Nov 26 '25 03:11

janmoesen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!