File download using Javascript, if file content is available but no file direct link
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';
精彩评论