给你一个我写的下载程序吧。<?
require("global.php");
$attach=readattach($fid);
$downfile="upload/$attach[postid].$attach[filekind]"; if ($attach[filekind]=='gif') {
header('Content-type: image/gif');
header('Content-Disposition: inline; filename="' . $attach[filename].".".$attach[filekind] . '"');
@readfile($downfile);
exit;
}elseif ($attach[filekind]=='jpg' or $attach[filekind]=='jpeg') {
header('Content-type: image/jpeg');
header('Content-Disposition: inline; filename="' . $attach[filename].".".$attach[filekind] . '"');
@readfile($downfile);
exit;
}elseif ($attach[filekind]=='jfif') {
header('Content-type: image/jfif');
header('Content-Disposition: inline; filename="' . $attach[filename].".".$attach[filekind] . '"');
@readfile($downfile);
exit;
}elseif ($attach[filekind]=='bmp') {
header('Content-type: image/bmp');
header('Content-Disposition: inline; filename="' . $attach[filename].".".$attach[filekind] . '"');
@readfile($downfile);
exit;
}elseif ($attach[filekind]=='png') {
header('Content-type: image/png');
header('Content-Disposition: inline; filename="' . $attach[filename].".".$attach[filekind] . '"');
@readfile($downfile);
exit;
}elseif ($attach[filekind]=='swf') {
header('Content-type: application/x-shockwave-flash');
header('Content-Disposition: inline; filename="' . $attach[filename].".".$attach[filekind] . '"');
@readfile($downfile);
exit;
}
query("update attachment set hits=hits+1 where attachmentid='$fid'");
$mime_type="application/octetstream";
header('Content-Type: ' . $mime_type);
//header("Content-Length: ".$fcon[fsize]);
header('Content-Disposition: inline; filename="' . $attach[filename].".".$attach[filekind] . '"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
@readfile($downfile);