Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8393607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:50:17+00:00 2026-06-09T19:50:17+00:00

Possible Duplicate: How to force a pdf download automatically? I’ve checked other forums, but

  • 0

Possible Duplicate:
How to force a pdf download automatically?

I’ve checked other forums, but I do not understand what they say. I’ve checked this link which people do seem to get the solution:

http://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/

I want to do a button which is done for downloading a PDF, the file is too big to see it online. So I want that button to force the browser to download the file. Asking or not asking the user. There will be different PDF name files so I need to make this button downloadable with PDF formats of various PDF files.

I’ve checked different webs and it seems it can be done using htaccess, but I honestly have no clue of how to do this. Can somebody help to show me how I can do this!?!?! Is there a simple way via CSS/html??

I’ve been stuck for a long while for such a small detail.

My code is simply:

<div class="Container for icons">
<a href="hugefile.pdf" alt=""><img href="icon.png" alt=""/>
</div>

Could somebody give me hand on this one?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:50:19+00:00Added an answer on June 9, 2026 at 7:50 pm

    You’ll need to modify the HTTP header returned to the client in order to accomplish this:

    • Force to open "Save As…" popup open at text link click for pdf in HTML

    Here’s a PHP code example:

    $path = "path/to/file.pdf";
    $filename = "file.pdf";
    header('Content-Transfer-Encoding: binary');  // For Gecko browsers mainly
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
    header('Accept-Ranges: bytes');  // For download resume
    header('Content-Length: ' . filesize($path));  // File size
    header('Content-Encoding: none');
    header('Content-Type: application/pdf');  // Change this mime type if the file is not PDF
    header('Content-Disposition: attachment; filename=' . $filename);  // Make the browser display the Save As dialog
    readfile($path);  //this is necessary in order to get it to actually download the file, otherwise it will be 0Kb
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: jquery: how to force a pdf download automatically? Afternoon folks, I have
Possible duplicate: why does the css min-width attribute not force a div to hae
Possible Duplicate: Force Download an Image Using Javascript Basically I want to have the
Possible Duplicate: Why are Exceptions not Checked in .NET? Coming from Eclipse/Java, I noticed
Possible Duplicate: How does GitHub change the URL but not the reload? Hi folks,
Possible Duplicate: Javascript force open a link in a browser I am working on
Possible Duplicate: Mobile site - force landscape only / no auto-rotate I have seen
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Double Negation in C++ code Let's say: bool var = !!true; It
Possible Duplicate: How to force C# App to run as administrator on Windows 7

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.