How to download files upon a click on a link

August 11, 2023 / How-to Guide

This guide explains how to download files upon a click on a link. In general, a file URL will open in a browser when you click on it. Instead, it is simple to make files download immediately after clicking.

Let us follow the steps:

  1. Open the .htaccess file in the File Manager to make changes.
  2. To make all of your desired file extensions downloadable when someone clicks the link, add the following line of code:
    AddType application/octet-stream .avi .mpg .mov .pdf .xls .mp4
  3. For instance, the line of code might seem as follows if you only wanted the .pdf files to be downloadable:
    AddType application/octet-stream .pdf
  4. Now, “Save” the changes.
  5. The changes will take effect. If you cannot see the changes on your live site, clear the cache.

This way, you can download files upon a click on a link.

If you want to explore more advanced ways, Check out our guide on How to download a file using curl command

 

Spread the love