i would like to ask how to retrieve a binary file(such as pdf file) and then avaliable for visitors to download?
could the fellowing code work?(file is blob type)
$sql = "select filename, file from mytable where xxx=yyy";
$result = mysql_query($sql, $linkptr);
list($tmpname, $tmpfile) = mysql_fetch_row($result);
if(detect_browser($HTTP_USER_AGENT)=='ie'){
header("Content-type: application/force-download");
}else{
header("Content-type: application/octet-stream");
}
header("Content-length: ".filesize($tmpfile));
header("Content-Disposition: attachment; filename=$tmpname");
readfile($tmpfile);
the main problem is that how to let user to download a file just click a hyper link, and the file is stored in database.