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 21,356 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,800 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,800 points 1,221 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,800 points 29,740 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,800 points 6,967 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,800 points 19,268 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,800 points 24,824 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,800 points 4,362 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,800 points 6,025 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 3,888 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,800 points 5,633 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,800 points 3,326 views
  • html
  • css
  • javascript
  • laravel
  • jquery
  • angularjs

Recent in PHP

  • How to create a service that wraps browser APIs for consistent usage across platforms? Apr 17
  • what is CURL ? Mar 19
  • How to check enabled PHP extensions? Mar 11
  • Why Isn't the MongoDB Extension Loading in PHP Despite Following Installation Steps? Mar 6
  • How to create WordPress themes? Feb 23
  • All categories
  • Generative AI Generative AI (1,454)
  • Power BI Power BI (1,316)
  • DevOps & Agile DevOps & Agile (4,138)
  • Data Science Data Science (100)
  • ChatGPT ChatGPT (30)
  • Cyber Security & Ethical Hacking Cyber Security & Ethical Hacking (1,057)
  • Data Analytics Data Analytics (1,266)
  • Cloud Computing Cloud Computing (4,053)
  • Machine Learning Machine Learning (337)
  • PMP PMP (1,069)
  • Python Python (3,488)
  • SalesForce SalesForce (201)
  • Selenium Selenium (1,624)
  • Software Testing Software Testing (58)
  • Tableau Tableau (608)
  • Web Development Web Development (3,972)
  • UI UX Design UI UX Design (24)
  • Java Java (1,358)
  • Azure Azure (157)
  • Database Database (858)
  • Big Data Hadoop Big Data Hadoop (1,907)
  • Blockchain Blockchain (1,673)
  • Digital Marketing Digital Marketing (121)
  • C# C# (141)
  • C++ C++ (272)
  • IoT (Internet of Things) IoT (Internet of Things) (390)
  • Kotlin Kotlin (8)
  • Linux Administration Linux Administration (389)
  • MicroStrategy MicroStrategy (7)
  • Mobile Development Mobile Development (395)
  • Others Others (2,386)
  • RPA RPA (653)
  • Talend Talend (73)
  • TypeSript TypeSript (124)
  • Apache Kafka Apache Kafka (84)
  • Apache Spark Apache Spark (596)
  • Career Counselling Career Counselling (1,091)
  • Events & Trending Topics Events & Trending Topics (28)
  • Ask us Anything! Ask us Anything! (71)

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