View Full Version : creating links to open/download files

03-09-2005, 02:10 AM
Is there a certain way to code a link to a file that will prompt the user to either open the file or save it to disk (as opposed to clicking on the link and having the file open inside the browser)?


03-09-2005, 03:40 AM
Technically, yes (or maybe... as no one seems to have actually tried it, yet): http://www.codingforums.com/showthread.php?t=51195

03-09-2005, 04:02 AM
Looks like you can do it with server-side programming (i.e., PHP)...Here's an excerpt from http://us2.php.net/header:

If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.

// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf