admin管理员组文章数量:1245170
my HTML5 web application receives a file as binary data via a websocket. Is there any way to initiate a file download dialog (via javascript) to save the received data to the users disk?
Thank you!
my HTML5 web application receives a file as binary data via a websocket. Is there any way to initiate a file download dialog (via javascript) to save the received data to the users disk?
Thank you!
Share Improve this question asked Mar 26, 2012 at 11:34 Herbert StiftlerHerbert Stiftler 1311 gold badge1 silver badge3 bronze badges2 Answers
Reset to default 6You need to build a dataUri and open a new window with this. Specific mimetypes can trigger the browser's automatic save as dialog.
Example data uri: "data:application/octet-stream,base64" + base64binary
Not yet, no. The new File API currently only covers reading. Update: See Peter's answer if you only need to do this on cutting-edge (and to date, non-IE) browsers, where you can do it with the data:
URI scheme.
The usual way to do this would be to receive the file via HTTP into a hidden iframe using Content-Disposition: attachment
to trigger the file download dialog, rather than receiving it via a web socket.
本文标签: javascriptreceive file via websocket and initiate download dialogStack Overflow
版权声明:本文标题:javascript - receive file via websocket and initiate download dialog - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740214068a2242541.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论