<?PHPinclude("DBDA.class.php");$db=NewDbda ();$bs=$_server["Query_string"];//gets the arguments passed by the submission interface.$BSS=substr($bs, 3);//Intercept = the value behind$sql= "Select video from Shangpin where id= ' {$BSS}‘";//get the video file path$str=$db->strquery ($sql);$WJM=substr($str, 13);//intercepting file names$lj=substr($str, 0,13);//The folder path where the file is intercepted $file _name=$WJM;//file name//To solve problems that cannot be displayed in Chinese$file _name=Iconv("Utf-8", "gb2312",$file _name); $file _sub_path=$_server[' Document_root '].$lj;//gets the document root directory where the current run script resides$file _path=$file _sub_path.$file _name;//the path to which the complete file is to be spelled//$file = include pathif(file_exists($file _path))//determine if a file exists{ Header(' Content-description:file Transfer ');//The header function is submitted to the table header is some of the download specifications Header(' Content-type:application/octet-stream '); Header(' Content-disposition:attachment; Filename= '.basename($file _path)); Header(' Content-transfer-encoding:binary '); Header(' expires:0 '); Header(' Cache-control:must-revalidate, post-check=0, pre-check=0 '); Header(' Pragma:public '); Header(' Content-length: '.filesize($file _path)); Ob_clean();//Ob_clean This function is used to discard the contents of the output buffer, if your site has a lot of generated files, you want to access the correct, you should always clear the buffer Flush();//the difference between ob_flush () and flush (). The former is the release of data from the buffer of PHP, the latter is not buffered or released data sent to the browser. So when the buffers are present, we have to use both ob_flush () and flush (). $file=fopen($file _path, "R");//opens the specified file, R represents read-only, and returns false if not found while(!feof($file))//determine if there is { //send The current file part to the browser Print fread($file,round(3000 * 1024));//Top Download speed 3MB//flush the content to the browser Flush();//Pass to Browser//sleep one second Sleep(1);//wait 1 seconds } fclose($file);//Close File /*ReadFile ($file _path); You can also use this method to send out the table header directly output, but there is no speed limit exit;*/}
PHP file speed limit download code