How To Make PDF File Downloadable In HTML Link - Edureka

82658/how-to-make-pdf-file-downloadable-in-html-link

  • Home
  • Community
  • Categories
  • Web Development
  • PHP
  • How to make PDF file downloadable in HTML link
How to make PDF file downloadable in HTML link 0 votes

I am giving link of a pdf file on my web page for download, like below

<a href="myfile.pdf">Download Brochure</a>

The problem is when user clicks on this link then

If the user have installed Adobe Acrobat, then it opens the file in the same browser window in Adobe Reader.

If the Adobe Acrobat is not installed then it pop-up to the user for Downloading the file.

But I want it always pop-up to the user for download, irrespective of "Adobe acrobat" is installed or not.

Please tell me how i can do this?

  • html
  • css
  • javascript
  • laravel
  • php
  • jquery
Aug 27, 2020 in PHP by kartik 37,520 points 19,916 views answer comment
  • flag

Your comment on this question:

Your name to display (optional):
Email me at this address if a comment is added after mine:
Privacy: Your email address will only be used for sending these notifications.
Add comment Cancel

1 answer to this question.

Your answer

Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Privacy: Your email address will only be used for sending these notifications.
Add answer Cancel
0 votes

Hello @kartik,

Try this:

<a href="./directory/yourfile.pdf" download="newfilename">Download the pdf</a>

Where newfilename is the suggested filename for the user to save the file. Or it will default to the filename on the serverside if you leave it empty, like this:

<a href="./directory/yourfile.pdf" download>Download the pdf</a>

Note:you should check compatibility first.

Check compatibility here: http://caniuse.com/#feat=download

Hope it helps!! Thank you!!

answered Aug 27, 2020 by Niroj 82,840 points comment
  • flag
  • ask related question

Your comment on this answer:

Your name to display (optional):
Email me at this address if a comment is added after mine:
Privacy: Your email address will only be used for sending these notifications.
Add comment Cancel

Related Questions In PHP

0 votes 1 answer

How do I add PHP code/file to HTML(.html) files?

Hello @kartik, You can't run PHP in .html ...READ MORE

answered Oct 22, 2020 in PHP by Niroj 82,840 points 676 views
  • html
  • css
  • javascript
  • laravel
  • php
0 votes 1 answer

How to include External CSS and JS file in Laravel?

Hello @kartik, The right way is this one: <script ...READ MORE

answered Oct 27, 2020 in PHP by Niroj 82,840 points 28,667 views
  • html
  • css
  • laravel
  • javascript
  • php
0 votes 1 answer

How to write file in UTF-8 format?

Hello @kartik, file_get_contents / file_put_contents will not magically ...READ MORE

answered Nov 5, 2020 in PHP by Niroj 82,840 points 6,074 views
  • html
  • css
  • javascript
  • laravel
  • php
0 votes 1 answer

How to check file extension in upload form in PHP?

Hello @kartik, Using if( $ext !== 'gif') might not ...READ MORE

answered Nov 8, 2020 in PHP by Niroj 82,840 points 17,127 views
  • html
  • css
  • javascript
  • laravel
  • php
0 votes 1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj 82,840 points 23,326 views
  • html
  • css
  • javascript
  • jquery
  • php
  • laravel
0 votes 1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj 82,840 points 3,323 views
  • html
  • css
  • javascript
  • laravel
  • php
  • jquery
0 votes 1 answer

How to enable Bootstrap tooltip on disabled button?

Hii @kartik, You can wrap the disabled button ...READ MORE

answered May 12, 2020 in JQuery by Niroj 82,840 points 5,121 views
  • html
  • css
  • javascript
  • laravel
  • jquery
  • php
+1 vote 2 answers

How to set cache false for getJSON in jQuery?

You can't pass any configuration parameters to ...READ MORE

answered Oct 7, 2020 in JQuery by Amit 140 points 2,953 views
  • html
  • laravel
  • php
  • jquery
  • javascript
  • css
0 votes 1 answer

How do I convert a PDF document to a preview image in PHP?

Hello @kartik, You need ImageMagick and GhostScript <?php $im = new imagick('file.pdf[0]'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo ...READ MORE

answered Aug 14, 2020 in PHP by Niroj 82,840 points 4,807 views
  • html
  • css
  • javascript
  • laravel
  • php
+1 vote 2 answers

How to make asynchronous HTTP requests in PHP?

Hello @kartik, Use this code: function post_without_wait($url, $params) { ...READ MORE

answered Sep 17, 2020 in PHP by Niroj 82,840 points 2,652 views
  • html
  • css
  • javascript
  • laravel
  • jquery
  • angularjs

Recent in PHP

  • What strategies can I use to limit the impact of HTTP 429 errors on dependent services in a microservice architecture? 4 days ago
  • What is PHPSESSID? Aug 8, 2022
  • getenv() vs. $_ENV in PHP Aug 8, 2022
  • How to make a nice "date picker" in PHP? Aug 8, 2022
  • Interface or an Abstract Class: which one to use? Aug 8, 2022
  • All categories
  • Artificial Intelligence Artificial Intelligence (3)
  • Generative AI Generative AI (173)
  • ChatGPT ChatGPT (21)
  • Apache Kafka Apache Kafka (84)
  • Apache Spark Apache Spark (596)
  • Azure Azure (157)
  • Big Data Hadoop Big Data Hadoop (1,907)
  • Blockchain Blockchain (1,673)
  • C# C# (141)
  • C++ C++ (272)
  • Career Counselling Career Counselling (1,060)
  • Cloud Computing Cloud Computing (3,698)
  • Cyber Security & Ethical Hacking Cyber Security & Ethical Hacking (408)
  • Data Analytics Data Analytics (1,266)
  • Database Database (858)
  • Data Science Data Science (78)
  • DevOps & Agile DevOps & Agile (3,805)
  • Digital Marketing Digital Marketing (121)
  • Events & Trending Topics Events & Trending Topics (28)
  • IoT (Internet of Things) IoT (Internet of Things) (387)
  • Java Java (1,296)
  • Kotlin Kotlin (8)
  • Linux Administration Linux Administration (389)
  • Machine Learning Machine Learning (337)
  • MicroStrategy MicroStrategy (6)
  • PMP PMP (536)
  • Power BI Power BI (808)
  • Python Python (3,223)
  • RPA RPA (653)
  • SalesForce SalesForce (122)
  • Selenium Selenium (1,571)
  • Software Testing Software Testing (58)
  • Tableau Tableau (608)
  • Talend Talend (73)
  • TypeSript TypeSript (124)
  • Web Development Web Development (3,188)
  • Ask us Anything! Ask us Anything! (70)
  • Others Others (2,245)
  • Mobile Development Mobile Development (395)
  • UI UX Design UI UX Design (24)

Join the world's most active Tech Community!

Welcome back to the World's most active Tech Community!

Sign up with Gmail Sign up with Facebook

OR

Password must have

At least 1 upper-case and 1 lower-case letter

Minimum 8 characters and Maximum 50 characters

SIGN UP Already have an Edureka Account? Login Forgot Password? LOGIN Don’t have edureka account? Sign Up resend ? Password must have

At least 1 upper-case and 1 lower-case letter

Minimum 8 characters and Maximum 50 characters

reset password Don’t have edureka account? Sign Up reset password Don’t have edureka account? Sign Up Send Code Don’t have edureka account? Sign Up

Subscribe to our Newsletter, and get personalized recommendations.

Google Sign up with Google facebook Signup with Facebook

Already have an account? Sign in.

webinar REGISTER FOR FREE WEBINAR X Years of Experience* Student 0-2 Years 2-5 Years 5-10 Years 10+ Years REGISTER NOW webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP "PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.

Từ khóa » Html And Css Pdf File Download