Friday 23 June 2017

How to convert Base64 code to file, and download it.





   <script type="text/javascript" src="jquery.js"></script>
 
 <script>
  function getImageDownload() {
 
debugger;
var filename ="download";
var contentType = "pdf"
var v = [];
v.push($('#gstNoProofBlob').val());
v[0] = v[0].replace(/\@/gi, '+');
//alert(v[0]);
var link = document.createElement("a");
var dName=filename+"."+contentType;
link.download = (dName);
link.href = "data:image/pdf;base64," + v[0];
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
delete link;
 }
 </script>

 <textarea rows="10" cols="50" id="gstNoProofBlob" name="gstNoProofBlob"> </textarea><br/><br/>    <input type="button" value="Download File" onclick="getImageDownload()" />






No comments:

Post a Comment