File Downloads
If you have files that you want your users to only be able to download by going through your web page, you can do so with the file download management tool.
Your web page must be a PHP web page. You need to add a few lines to the very top of your web page to tell the download management tool where the files are, and which files are authorized for download:
<? $authMySanDiego = true; require_once('/web/includes/login.php'); require_once('/web/includes/downloads.phpi'); $files = new DownloadManager('/path/to/directory'); ?>
This must be at the very top of your web page. There cannot be any HTML before, nor even any spaces or blank lines. Any stuff above the PHP code listed above will cause the downloads to fail.
You can modify login.php as normal.
Store your files outside Sites
Since you’re doing this to require people to go through a web page (requiring a login) before they can download files, store the files outside of your Sites folder. Otherwise they’ll be able to bypass your login page and download the files directly. Instead, create a special folder for downloads in your home directory, and store your downloads there.
Showing available files
You’ll presumably want to show all of the files that are available for download. You can use $files->show() for this:
<? $files->show(); ?>
This will display the downloads in alphabetical order, along with the size of the file and the time it was last modified. They will be displayed in a table of class “files”. You can modify the table’s display using style sheets as normal.
You can also create your own links to the downloads if you want; the links must be to the full filename (including index.php if that’s the filename) of the page displaying the downloads, a slash, and then the filename of the download.
The safest way to get the link URLs for creating custom links is to use $files->show() to display them, copy the links from there, and then remove $files->show().
The old version
This PHP include file replaces a very old one using /web/includes/downloads.php (no ‘i’). If you need a feature from that older version, let me know.
