How do I force an open/save dialogue on a download?
Basically i've got a pdf file that I want people to access as a download. When you click on it, it will automatically open the file for you. But I want it to display the open/save dialogue that you get when downloading a zip or unknown file type.
It is for a website that I am making for my church, so I want to make it as easy to use as possible. So I don’t to put the file in a zip, or expect people to know how to right click and select ‘save target as’.
Is there an easy way of doing this? Perhaps something to do with target= something?
Thanks for any help you can give!
Can be done with (for example) PHP by sending header information. Not sure it can be done with pure HTML, though.
The easy way is to zip it up. Nothing can be done in HTML to force and even sending headers may not work in IE.
For the other you can force the browser to display a "Save As/Open from current location" dialogue box when it wants to write known binary content to the client.
myTempWindow = window.open(x,’’,’left=10000,screenX=10000’);
The official approach for this is to use a http header to request the display of user permission dialog box. This header is known as "Content-Disposition."
Following is the sample for server-side based applications, (almost all http libraries provide an API to set an http header).
HttpResponse.setHeader("Content-Disposition "," attachment; filename= whatever.pdf");
I beleive you can even force Content-Disposition to fit in a meta tag if you don't have the ability to issue server side commands. Something like:
<META HTTP-EQUIV="Content-Disposition" CONTENT="attachment; filename=whatever.pdf">
Apache .htaccess: ForceType application/octet-stream pdf
Thankyou, i'll try it soon.
Even with an application/octet-stream header IE may decide to "sniff" the response content and act according to the user's PDF binding.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)