<?php
	include "conn/conn.php";		//链接数据库
	$address = $_GET[id];			//获取文件的名称
	if($_GET[action] == "video"){
		$a_sql = "select address,downTime from tb_video where address = '".$address."'";
		$a_rst = $conn->execute($a_sql);		//根据文件名称执行查询语句
		if(!$a_rst->eof){
			$downtime = array();
			$downtime["downTime"] = $a_rst->fields[1] + 1;    //更新下载次数
			$updata = $conn->getupdateSql($a_rst,$downtime);
			$conn->execute($updata);
			$path = "upfiles/video/".$address;	//获取文件在服务器中存储的位置
		}
	}
if(file_exists($path)==false){		//判断文件是否存在
 echo "<script>alert('您下载的文件已删除');history.back();</script>";
 exit;
}
$filename=basename($path);
$file=fopen($path,"r");
header("Content-type:application/octet-stream");
header("Accept-ranges:bytes");
header("Accept-length:".filesize($path));
header("Content-Disposition:attachment;filename=".$filename);
echo fread($file,filesize($path));
fclose($file);
exit;
?>