Discussion Locked

how to create a download?

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I want to make a pdf file I have created to be available for download from one of my web sites, can anyone tell me how to do this?

7 replies

by okujava

if you use jsp/servlets, then call:
response.addHeader("Content-Disposition", "attachment; filename=\"foo.txt\"");
OutputStream os = response.getOutputStream();

the client should see a download window and
all you write in os, should be passedto the client.

hope it helps... :)

by daz'n'ash

Thank you for your advice, but I am not familiar with jsp/servlets. If I can do it with HTML or JavaScript, that would be easier for me.

by dklippert

If you want them to have the choice of downloading or opening the file, just put a hyperlink on the web page.

by daz'n'ash

That is what I have tried, although the same as I already did that with a zip file, it doesn't seem to want to work with the adobe pdf file.

by wask

The easiest way would be to provide a hyperlink to the pdf file, in case the client wishes to view the file online. But instead if the client wishes to download the file for viewing it offline, then just "zip" the pdf file and provide a link to the .zip file. however, If the browser in use does not have a pdf plugin, it would automatically show the user a download window.

I hope this helps.

by daz'n'ash

Thank you for your answer, it seems it is about as close as I am going t get for the answer I require.

This discussion is closed to new replies.