Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

londonweb

macrumors 6502
Original poster
Sep 14, 2005
260
0
london
Does anyone know how to offer files as downloadable from a web site?

For example, I want to offer a pdf file for download, instead of a simple link to open it in a new page. Is it possible to instigate the user's download manager and have it download to the desktop, for instance?
 
I'm not sure if you know php but you can do it via the header (something like this, you may have to tweak a little):

Code:
   header("HTTP/1.1 200 OK");
   header("Content-Length: $filesize");
   header("Content-Type: application/force-download");
   header("Content-Disposition: attachment; filename=$filename");
   header("Content-Transfer-Encoding: binary");
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.