Web Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignWeb Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old May 5th, 2006, 06:31 AM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 4
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.

Reply With Quote
  #2  
Old May 5th, 2006, 06:36 AM
Icon's Avatar
Icon Icon is offline
Command Line Warrior
Click here for more information
 
Join Date: Sep 2005
Posts: 621 Icon User rank is Private First Class (20 - 50 Reputation Level)Icon User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 22 h 27 m 25 sec
Reputation Power: 3
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');
?>

Reply With Quote
  #3  
Old May 5th, 2006, 08:25 AM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 4
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?

Reply With Quote
  #4  
Old May 5th, 2006, 12:21 PM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 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!

Reply With Quote
  #5  
Old May 9th, 2006, 07:01 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 5
Send a message via MSN to Spongy
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

Reply With Quote
  #6  
Old May 10th, 2006, 09:20 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignWeb Development > Providing a link to download a pdf


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway