PDA

View Full Version : Create Download File Button


tux
03-04-2009, 10:27 PM
Hi all,

I have a txt file on the server and want to be able to download it when a button/link is clicked instead of the file opening in the browser.

How can this be done.

Thanks, Paul

cocoonfx
03-04-2009, 11:13 PM
<a href="test.txt.zip"><img src="test.png" width="120" height="120"/></a>

this works a dream.

cocoonfx
03-04-2009, 11:14 PM
or

<?php
$file = $_GETfile;
header("Content-type: application/force-download");
readfile("path/" . $file);
exit();
?>

davidj
03-05-2009, 06:26 AM
or as your file is tab delimited why not change the extension to csv

excel will be invoked if you choose the open option when prompted