php根据数据库记录实现文件下载
php文件下载是一款根据数据库中的记录再用php中的header来实现文件下载。
<?php include './admin/connect.php'; @extract($db->get_one("select * from movieinfo where id='".$_GET['id']."'")); $db->query("update movieinfo set downnum=downnum+1 where id='".$_GET['id']."'"); //控制下载 $url2="./admin/";//存放电影的路径 if($localaddress) { $newname=$localaddress; $movieurl=$url2.$newname; } $type=basename($movieurl); $type= substr(strrchr($type,'.'),0); $filename=$title.$type; $file=fopen($movieurl,'r'); ob_end_clean(); header('Content-type: application/octet-stream'); header('Accept-Ranges: bytes'); header('Accept-Length:'.filesize($movieurl)); header("Content-Disposition: attachment; filename=".$filename); echo fread($file,filesize($movieurl)); fclose($file); exit;
教程地址:http://www.phprm.com/code/33277.html
欢迎转载!但请带上文章地址^^