|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
||||
|
||||
|
Providing a link to download a pdf
Hi there! What is the HTML code to provide a hyperlink (or what ever it's called in this case) so the user can download a small pdf and get an alert saying where they want the file saved. I'm thinking this is quite easy code, but I can't find it on google because I don't know what it's called. Maybe it requires not just HTML but php or Javascript, but I just need that little pointer to get there.
|
|
#2
|
||||
|
||||
|
http://php.net/manual/en/function.header.php
<?php // 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 readfile('original.pdf'); ?> |
|
#3
|
||||
|
||||
|
Thanks Icon for that. However, are these 3 different solutions to the same exercise, or 3 different solutions to 3 different pdf styles. I have the somefile.pdf situated in a directory in a website and somewhere down the page of a html file I wan't to say "download pdf file here". OK, from your solution, it looks like I use php, no problem, but with the header function I need to make sure the function is before any input/output is done by the html. How I am I going to achieve this in the middle of the page?
|
|
#4
|
||||
|
||||
|
Umm! I've just worked it out now, all you need to do is put a normal html link, pointing to the pdf on your website.
Like this:- <a href="somefile.pdf">Download (pdf)</a> No complications of php header functions needed here! The file will be save in the default location set by the download manager of your browser. Nice and simple that's how I like it! |
|
#5
|
||||
|
||||
|
Hmm... I thought you wanted an 'automated' Save As...
With a direct link to the pdf itself it will startup Adobe Reader. For a download of the file the best thing is to go with the solution Icon gave you. That way the file will be downloaded instead of opened. Good luck. Spongy
__________________
Work to live, don't live to work |
|
#6
|
||||
|
||||
|
The benefit of SnapCracker's solution is the way it seems to hide the true position of the file on your server... I think overall they have the same results...
The ability to download the file instead of starting up Adobe Reader is really more of a client issue than something you should worry about. I believe a client can disable the Adobe Reader plugin in the Acrobat application.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Web Development > Providing a link to download a pdf |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|