admin管理员组文章数量:1336632
From this string we get from DataURL, what's the best way to download this as a file?
So far what I got was using a basic window.open("myDataURL");
, but I'm not able to change the file name in this way.
window.open('data:application/msword;base64,0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAA
PgADAP7/CQAGAAAAAAAAAAAAAAACAAAANQAAAAAAA
AAAEAAANwAAAAIAAAD+////AAAAADQAAABsAA/',
'_blank','height=300,width=400');
I was wondering if there's any way to handle this data properly.
From this string we get from DataURL, what's the best way to download this as a file?
So far what I got was using a basic window.open("myDataURL");
, but I'm not able to change the file name in this way.
window.open('data:application/msword;base64,0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAA
PgADAP7/CQAGAAAAAAAAAAAAAAACAAAANQAAAAAAA
AAAEAAANwAAAAIAAAD+////AAAAADQAAABsAA/',
'_blank','height=300,width=400');
I was wondering if there's any way to handle this data properly.
Share Improve this question edited Jan 9, 2012 at 17:35 Ry-♦ 225k56 gold badges492 silver badges498 bronze badges asked Jan 9, 2012 at 17:33 eBergamoeBergamo 1011 gold badge3 silver badges6 bronze badges 3- See stackoverflow./a/6465780/27862 – user123444555621 Commented Jan 9, 2012 at 17:46
- I've seen this question before, the file name bees "rVPjLUq1.part", just as if I were using the example I posted above. – eBergamo Commented Jan 9, 2012 at 18:02
- As Wladimir Palant writes, the issue has been discussed on the W3C mailing list, but "this doesn't seem to have made it into any specification so far, let alone browser implementations." I'm afraid there hasn't been any progress in that matter. – user123444555621 Commented Jan 10, 2012 at 10:51
2 Answers
Reset to default 3you 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/rfc/rfc2397 for reference, there's nothing in the specification to support a filename.
本文标签: filewriterDownloading file from DataURL in JavaScriptStack Overflow
版权声明:本文标题:filewriter - Downloading file from DataURL in JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742356471a2459515.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论