Downloading file from DataURL in JavaScript

a 夏天 提交于 2019-12-03 00:29:20

you can add a download attribute to the anchor element. sample:

<a download="abcd.zip" href="data:application/stream;base64,MIIDhTCCAvKg........">download</a>

Try this:

data:application/msword;fileName=test.doc;base64,0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAACAAAANQAAAAAAAAAAEAAANwAAAAIAAAD+////AAAAADQAAABsAA/

But this is just a guess from googling around and might be browser-dependent. The real answer to this is, you can't - See http://www.ietf.org/rfc/rfc2397 for reference, there's nothing in the specification to support a filename.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!