In the PHP code, you need to change this line: $files = array("test.txt","test2.txt"); to be the names of all your files.
You should then link to the file to in to following manner <a href="filedownload.php?index=0"> where 0 is the index of the file in the array.
So, the link above will download text.txt, and a link like this <a href="filedownload.php?index=1"> would download test2.txt.
<?PHP ####################################################### # This script is Copyright 2003, Infinity Web Design # # Written by Ryan Brill - [email protected] # # All Rights Reserved - Do not remove this notice # ####################################################### $files = array("test.txt","test2.txt"); $index = $_GET["index"]; $filename = $files[$index]; if (is_file($filename)) { header("Content-type: application/octet-stream"); header("Content-Length: ".filesize($filename)); header("Content-Disposition: attachment; filename=\"".$filename."\""); $fp = fopen($filename, 'rb'); fpassthru($fp); fclose($fp); } else { echo "File not available."; } ?>
Tested in: IE6, Opera 7, NN4.7, NN7, Mozilla Firebird, and Mozilla 1.2.
Works in: IE6, Mozilla Firebird, and NN4.7
Works partialy in: NN7 and Mozilla 1.2
Doesn't work in: Opera 7
In NN7 and Mozilla 1.2, the file downloads, but a .php extention is added.
Copyright© 2003, Infinity Web Design