How to Create a Download Link

Create links that download files rather than display them

Example of a web browser file download
Bradley Mitchell

Years ago, when a visitor to your website clicked a link that pointed to a non-HTML document like a PDF file, an MP3 music file, or even an image, those files would download to that person's computer. Today, that is not the case for many common file types.

Instead of forcing a download on these files, today's web browsers simply display them inline, directly in the browser viewport. PDF files will be displayed in the browsers, as will images. MP3 files will be played directly in the browser window rather than saved as a download file. In many cases, this behavior may be perfectly fine. In fact, it may be preferable to a user having to download the file and then find it on their machine in order to open it. Other times, however, you may actually want a file to be downloaded rather than displayed by the browser.

The most common solution most web designers take when they try to force a file to download rather than be displayed by the browser is to add explanatory text next to the link suggesting that the customer use their browser options to right-click or CTRL-click and choose Save File to download the link. This is really not the best solution. Yes, it works, but since many people don’t see those messages, this isn’t an effective approach and it can result in some annoyed customers.

Instead of forcing customers to follow specific directions that may not be intuitive to them, this tutorial shows you how to set up both the above methods and ask your readers to request the download. It also shows you a trick for creating files that will be downloaded by nearly all web browsers, but that can still be used on the customer’s computer.

How to Have Visitors Download a File

  1. Upload the file you want your website visitors to download to your web server. Make sure you know where it is by testing the full URL in your browser. If you have the correct URL the file should open in the browser window.

    1. Edit the page where you want the link and add a standard anchor link to the document.
    <a href="/documents/large_document.pdf">Download the large document</a>
  2. Add text next to the link telling your readers they need to right-click or ctrl-click the link in order to download it.

Right-click (control-click on a Mac) the link and choose “Save Link As” to save the document to your computer

Change the File to a Zip File

If your readers ignore the instructions to right-click or CTRL-click, you can adjust the file to something that will be automatically downloaded by most browsers, as opposed to that PDF which is read inline by the browser. A zip file or other compressed file type is a good option to use for this method.

  1. Use your operating system compression program to turn your download file into a zip file. 

  2. Upload the zip file to your web server. Make sure you know where it is by testing the full URL in your browser window.

  3. Edit the page where you want the link and add a standard anchor link to the zip file.

<a href="/documents/">Download the large document</a>


  • Most operating systems have some compression software built in. If yours doesn’t, you can look up “zip files” in a search engine to find a program to build them for you.
  • You can use this technique for images, movies, music, and documents, as well as PDF files. Anything you can compress as a zip file you can post to your site for download.
  • You can also compress multiple files into one zip file, to let your customers download a collection of files with one click.
  • If none of the above methods is appealing, you can also force a download with PHP.