开发者

Save file to the local system using browser with the specified filename and extension using html & javascript without server interaction

We are using HTML5 and javascript in one of our applications. The requirement is when the user clicks on a button we should download a file containing all the user entered data. There should be no server interaction to do this.

B开发者_如何学Cy using ActiveX object we can do this. But it is limited to Internet Explorer only.

By setting the response headers at the server also we can achieve this. But we can't use server interaction to do this.

We tried to use base64 data with mime type as 'application/octect-stream'. It is downloading "xxx.part" file to the local system with the exact data. But we are unable to set our own file name and extension (as we can't use .part as extension) to the file.

Please suggest us a way to download a file from the browser without server interaction with the desired file name and extension that works with all the browsers.


Currently not possible without using ActiveX or Flash. Take a look at Downloadify and see if it works for you.


We tried to use base64 data with mime type as 'application/octect-stream'

Have you tried setting appropriate response header?

Response.AppendHeader("Content-Disposition", "attachment; filename=name.ext");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜