imageAction.php
<?php
//數據庫部分自己改
$link=mysql_connect("localhost","root","123456");
mysql_select_db('test',$link);
mysql_query("set names gb2312"); <br>
$recid = $_GET['recid'];
$query="select * from tb_tpsc where id = $recid";
$result=mysql_query($query);
$info = mysql_fetch_array($result);<br>
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: image/jpeg');
//想辦法獲取文件擴展名,我這裏默認的給的是jpeg的,這個妳沒有存起來
header("Content-Disposition:filename=". $info['tpmc'] . ".jpeg");
echo $info['file'];
>在模板裏面寫:<a href="路徑/imges/recid/圖片文件的id">下載</a>
具體的代碼以及傳遞的參數,依據妳的實際應用修改。