Beyond Fusion
Follow us on Twitter

Forcing a File download with PHP

This tutorial teaches you how to use a simple PHP script to force a file download. This is useful for files such as PDFs where you want the file to download rather than open in a browser window.

The technique can be expanded greatly in conjunction with a database and additional code for restricting access to certain visitors, tracking downloads, limiting how many times a file can be downloaded by a particular visitor, etc.

Tutorial and code by: Chuck Joslin

Tested and Works with:

Firefox 1.0 Opera 5.74
Internet Explorer 5+ Mozilla 1.73

You are using:

Working Example

Click on the icon to download the code:

Download Script

Step 1. Get the code by clicking on the link above. This will use the actual script to download itself to your computer. Save the file to your assets folder in your site folder. (Rename the script if you wish.)

Step 2. Assign values to the two variables in the script. The path to the file and the name of the file.

Step 3. Save the script and FTP it to your web space. It can go anywhere you wish.

Step 4. Add text or image object on your page in Fusion to use as a link and open the objects link window.

Step 5. Add an external link to the script like: (assuming you FTP'd the script to your site's root directory)


Buy AllWebMenus

Works with Fusion 2015

NetObjects Fusion is Registered Trademark of NetObjects, Inc.


Once You Know, You Newegg