I've got a form that allows people to upload doc files to the server, the name is stored in the database. What I would like if for them to be able to download the uploaded file in future.
Here is what I got so far... What I'm looking for is code to put a "download" button so that when they press it, it pops up a save the file window.
Thank you in advance for all your help
--- CODE ---
<?
include "classes/db_config.inc.php";
$id = $_REQUEST['id'];
$query = "SELECT * FROM testdata WHERE id='$id'";
$result = mysql_query( $query );
if( $result && $contact = mysql_fetch_object( $result ) )
{
$id = $contact -> id;
$fname = $contact -> name_first." ".$contact -> name_middle.". ".$contact -> name_last;
$address = $contact ->address." ".$contact -> city." ".$contact ->state.$contact ->zip;
$email = $contact -> email;
$homephone = $contact ->ph_hmno_a.$contact -> ph_hmno;
$cellphone = $contact ->ph_cno_a.$contact -> ph_cno;
$fn = $contact -> file_name;
$rs = $contact -> file_size;
?>
<p><b><left>Contact Information</left></b></p>
<table border="1" cellpadding="3" cellspacing="3">
<tr>
<th align="left">Name</th>
<td align="left"><?php echo($fname) ?></td>
</tr>
<tr>
<th align="left">Address</th>
<td align="left"><?php echo($address) ?></td>
</tr>
<tr>
<th align="left">E-mail</th>
<td align="left"><?php echo("<a href='mailto:$email'>$email</a>") ?></td>
</tr>
<tr>
<th align="left">Home Phone</th>
<td align="left"><?php echo($homephone) ?></td>
</tr>
<tr>
<th align="left">Cell Phone</th>
<td align="left"><?php echo($cellphone) ?></td>
</tr>
</table>
<hr color="#000000" width="60%" align="left">
<p><b><left>File</left></b></p>
<table border="1" cellpadding="3" cellspacing="3">
<tr>
<th align="left">File Name</th>
<td align="left"><?php echo($rn) ?></td>
</tr>
<tr>
<th align="left">Size ( bytes )</th>
<td align="left"><?php echo($rs) ?></td>
</tr>
</table><br><br>
<? // NEED CODE HERE TO DOWNLOAD THE FILE ON SERVER
?>
<?
}
else
{
die( "Error: Could not get contact from database. ".mysql_error() );
}
?>