i'm generating file using javascript user download looks so:
<a href="data:application/octet-stream;charset=utf-8;base64,zm9vigjhcg==">text file</a>
what need file name user set when saved file can display on website.
how can achieve that?
simple answer is: can't.
complicated answer is:
you can create script pre-set name of file user. create pop-up or prompt ask naming file. after can edit download attribute javascript , user download file name. (if doesn't change in download dialog) this:
var filename = prompt("please name file", "originalfilename"), filelink = document.getelementbyid('file'); if(filename!= null){ filelink.download = filename; filelink.innerhtml = filename; }
<a download='originalfilename' id="file" href="data:application/octet-stream;charset=utf-8;base64,zm9vigjhcg==">text file</a>
live example on https://jsfiddle.net/6o2fxcvd/1/
Comments
Post a Comment