HTML5 File API downloading file from server and saving it in sandbox

前端 未结 3 1071
暖寄归人
暖寄归人 2020-12-02 05:15

I\'m trying to understand HTML5 API. I\'m designing the web application where the browser client need to download multiple files from server; user will perform something wit

3条回答
  •  醉酒成梦
    2020-12-02 05:53

    My trick is to simply append IFRAMEs with a "src" attribute pointing to your multiple downloads. The server site should send the files with a "disposition: attachment" header and then the client will try to store the file locally. The only "problem" is that the IFRAMEs will stay in your DOM tree as debris until the user leaves or reloads the page. Make the IFRAME invisible (e.g. width=0; height=0;) and you are ready to go! All browsers.

提交回复
热议问题