1

I want to transfer a file from server to client via JavaScript decode its content from base64 tp plain text and provide a link on my HTML page to download this decoded plain text file for saving to disk. Is this possible?

I've tested around with AJAX calls which get me some base64 data from my PHP script, but how can I create a link with a datafile download on the fly?

bignose
  • 30,281
  • 14
  • 77
  • 110
tomcat.exe
  • 95
  • 1
  • 6
  • why would encode a file into base64 in an ajax response ... why would you not just provide the file directly from your server to the end user? – cmorrissey Dec 03 '14 at 16:55
  • 1
    Have a look at this [question][1] and also HTML5 Web Storage [1]: http://stackoverflow.com/questions/3665115/create-a-file-in-memory-for-user-to-download-not-through-server – Tom Chamberlain Dec 03 '14 at 17:06
  • Encoding was just an example. Imagine you would like to encrypt a file and provide the result of the encryption as a link. [Thank you Tom C. for the hint. This was exactly what i was looking for. `a.attr("href","data:application/octet-stream;base64,` for example – tomcat.exe Dec 05 '14 at 20:50

0 Answers0