1. Technology

How To Create a Download Link

Write Links That Download Files Rather than Display Them

By

Download progress bar
SpiffyJ/E+/Getty Images

Sometimes you have items on your website that you want your customers to be able to download to their home computer. Things like large documents and PDF files, long videos, or songs. But these files are automatically opened in the browser window rather than saved as a download file.

The most common solution most web designers take 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. But since many people don’t see those messages, this isn’t as effective, and can result in some annoyed customers.

This tutorial will show you how you can set up both the above method, and ask your readers to request the download. And it will also show 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.

Difficulty: Average

Time Required: 10 minutes

What You Need:

Here’s How:

Get Your Customers to Do It

  1. Upload the file you want your customers 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.
    /documents/large_document.pdf
  2. 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>
  3. 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: a zip file or other compressed file type.

  1. Use your operating system compression program to turn your download file into a zip file. How to Zip Files On a Mac Zip Files on Windows
  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.
    /documents/large_document.zip
  3. Edit the page where you want the link and add a standard anchor link to the zip file.
    <a href="/documents/large_document.zip">Download the large document</a>

Tips:

  • 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 bunch of files with one click.
  • If none of the above methods appeals you can also force a download with PHP.

Learn More About Links on Web Pages

Links use the the A element to connect text and images to other documents on the web. Add a Link in HTML | Add a Link in Dreamweaver | Add Internal Links | Change Link Color Use a Link Checker

©2014 About.com. All rights reserved.