Initiate file download from javascript

JavaScript

If the code of file downloading must be created using a pure client scripting then the solution is to use the following trick:


var content = "some base64 encoded zip file";
location.href="data:application/zip;base64,"+content;

That should work the same way it does for embedded images with <img src="data:image/jpeg;base64,[base64 encoded image]" />

Post a Comment

Previous Post Next Post