Forum Moderators: mack
Very new to webmaster-ing.
I have set up a folder on my server for downloading free pdf's and other files >>> www.mydomain.com/downloads/abc.pdf
When clicked on, it opens up the pdf.
How can I set it up so that when it is clicked on, they get the standard box popping up and asking if they want to "run" or "save", instead of it opening automatically?
thanks in advance
then the downloader.php will contain the following;
$dfile = $_GET['dfile'];
$path = 'http://www.yourdomain.com/'."your_pdf_folder".'/';
$ffile = "$path"."$dfile";
header('Content-type: application/pdf');
header("Content-Disposition: inline; filename=$dfile");
readfile("$ffile");
First, I changed the extension on the file to jpgx.
Then I added the following line to my httpd.conf file:
AddHandler send-as-is jpgx
Then I modifed the jpg file by adding HTTP header info to the top of the file (followed by a blank line). It looks like this:
Status: 200 OK
Last-Modified: Fri, 25 Mar 2005 03:57:53 GMT
Content-Length: 208002
Content-Type: image/jpeg
Content-Disposition: attachment; filename=3600.jpg
The most important part is the last line - It tells the browser to download it (not display it), and it tells it a corrected file name - so the jpgx turns into jpg.
Even in a shared hosting environment where you don't have access to the httpd file you may be able to use the extension .asis since that's an Apache default extension for doing what I just described.
That approach works in just about all cases except IE for Mac. If I encounter IE for Mac I zip the file and have them download a zipped jpg.