• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Creating a downloadable link on my website

I have a fillable PDF file that I would like to offer as a download on my website...I need to create a link that when clicked will prompt the user to download the file.
0
felkamau
Asked:
felkamau
3 Solutions
 
erikTsomikSystem Architect, CF programmer Commented:
JUst do this
<a href="http://domainname/filename.pfd">Download Me</a>
0
 
felkamauAuthor Commented:
this only opens the pdf...I need to force a download
0
 
Loganathan NatarajanLAMP DeveloperCommented:
do you use any SERVER Side scripting in your website?  like PHP/ASP/JSP etc.,?
0
 
dipakdave1983Commented:
Well, you have to explicitely set Header to download using appropriate syntex of your webpage.

Content-Type: application/force-download

So Trick is 1) read entire file as .bin 2) clear the response stream ( it will clear some default contents such as <html contenttype.....>3) set content type as above into HEADER  and  inject .bin file contents to output

example for PHP :
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=\"".basename($file)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
readfile("$file");

0
 
felkamauAuthor Commented:
I saved it as a zip file...problem solved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now