Force Download
Posted: Thu Dec 18, 2008 11:58 pm
I was wondering how you could force a file to down in a while statement in php? Ok maybe that's not the greatest explanation; maybe you guys can get it from looking at the following code:
How do I force them to DOWNLOAD the file no matter what file extension when they click download, instead of opening it in the browser? Thanks
Code: Select all
<?php
if ($handle = opendir("$username_saved/extras")) {
echo "<table cellspacing=10>";
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "
<tr>
<td width=50%>$file</td>
<td width=25%><a href=$username_saved/extras/$file>
DOWNLOAD</a>
</td>
<td width=16%></td>
<td width=25%>DELETE</td>
</tr>
";
}
}
closedir($handle);
}
?>