开发者

File download using Javascript, if file content is available but no file direct link

开发者 https://www.devze.com 2023-02-05 07:08 出处:网络
Can anyone guide me to imple开发者_如何学Pythonment a javascript function, which takes as Argument \"file content\" (read from web service as httpresponsebody), and show a file save or file open dialo

Can anyone guide me to imple开发者_如何学Pythonment a javascript function, which takes as Argument "file content" (read from web service as httpresponse body), and show a file save or file open dialog in browser?

Direct link to file is not available, all I can read is file content via web service. Can anybody guide me here?


I think you would have to use JavaScript to redirect to some PHP (Or any other server side scripting language) file that sends the correct headers. It would stay on the page as long as you get the headers right, here is an example.

So after setting up your server side script to serve the file. You will need to redirect the user to that file like so.

window.location = 'http://myserver.co.uk/download.php';
0

精彩评论

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

关注公众号