[thelist] Force download of pdf using coldfusion
Keith
cache at dowebs.com
Thu Jan 10 18:14:10 CST 2002
> Hi all,
>
> I searched the archives on this issue and found some good info, but
> still couldn't quite get this work. I'd like to have a link that a
> user can click to download a pdf file to their hard drive (not open in
> browser). I tried using the cfcontent tag, but to no avail. Here's
> what I tried
>
> <cfcontent type="application/pdf" file="#path##file_name#.pdf">
>
> which causes the file to open in the browser. If I modify the type by
> changing it to say type="text/pdf", the download prompt opens like I'd
> like, but the file name to save is the name of the cf file this code
> resides in and the file type is coldfusion.
have no idea what syntax you'd use for Cold Fusion, but with a cgi we
force a download by first telling the browser to ignore the content type and
ignore tying to figure it out, then do what a Content-Disposition tells it to
do. Using type="text/pdf" will fail to get results in IE4, see
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q182315
$file_name = "whatever.pdf";
print "Content-Type: bad/type\n";
print "Content-Disposition: attachment; filename=$file_name\n\n";
keith
More information about the thelist
mailing list