Forum Moderators: open
If the user does not have adobe reader installed...the click will result in a "save as..." dialog box...
you can possibly prompt your users to right-click the link and "save as..." to download the file...
or....go ahead and open the file in adobe reader then FILE /SAVE A COPY to get the .pdf to their desktop (or wherever...)
hope that helps!
Tera
Here is the problem: browsers associate files with helper applications. So if directly linked to, the browser will always recognize a PDF (or a .gif, .jpg, etc.) and display it in the browser using a plug in, or prompt you to install the plug in. In some browsers this is true even if you change the extension - it "sniffs out" the file type by reading in the file headers.
So if you want to force a download of a known file type, I know of only one way to do it: create a server-side application that supplies an unknown content-type.
When you use an application to output to the browser (perl, PHP, asp, etc.) you need to sent the mime type to the CGI gateway or it will generate an error. Normally this is
content-type: text/html
or for PDF,
content-type: application/pdf
or
content-type: application/octet-stream
When you send a bad content-type, the browser doesn't know what to do with the file. So it prompts for a download. You can make this really slick by pre-populating the filename box. This is especially cool in online purchases, where the actual file is stored in a hidden location. You can supply a PDF file called 123456.hid and send it as user_manual.pdf.
So if you get anything I've said above, here is a perl example on how to do this. Note "bad/type." That can be anything except a known mime type, as "herbs/widgets" or "sgfdfsdf/dfsd".
$CRLF = "\x0d\x0a"; #define octal line feed
$file = '/full/path/to/123456.hid';
$filename = 'manual.pdf';
# Get the length of the content, it must be file length + 1
if (-e $file) { $size = -s $file; $size++; }
Print to browser.
print "Content-type: bad/type$CRLF";
print "Content-Length: $size$CRLF";
print "Content-Disposition:attachment;filename=$filename$CRLF$CRLF"; ## Two newlines
open (FILE, "$file_loc") or &some_error_routine(!$);
while (<FILE>) { print; }
close (FILE);
That's it, it will download.
Over at 456Bereastreet there is javascript code for this, so you need to use target:blank.
[456bereastreet.com...]