Add this snippet to your .htaccess file to force downloads for specific file types:
If you are just browsing and want to stop Chrome or Edge from opening every PDF you click, you can change your local settings. download file instead of opening in browser
When you click a link for a PDF, image, or video, most modern browsers like Google Chrome or Mozilla Firefox try to be helpful by opening it in a new tab. While this is great for a quick preview, it can be frustrating if you actually need to save the file for later. Add this snippet to your
If the HTML attribute isn't enough (or if you are dealing with cross-origin files), you need to change how the server talks to the browser using the Content-Disposition header . Set the header to attachment instead of inline . How to do it: If the HTML attribute isn't enough (or if
header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="file.pdf"'); readfile('file.pdf'); Use code with caution. 3. For Users: Browser Settings & Tricks