Home > Backend Development > PHP Tutorial > PHP breakpoint resume download function_PHP tutorial

PHP breakpoint resume download function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:07:08
Original
992 people have browsed it

Let’s take a look at using PHP to resume the upload. This function is a great time saver

Let’s take a look at using PHP to resume the upload. This function is a great time saver

header("Cache-Control: public");
header("Accept-Ranges: bytes");

$file = "a.rar";
$filename = "a.rar";

$size=filesize($file);
$size1=$size-1;
//Get byte range
if(isset($_SERVER['HTTP_RANGE'])) {
List($name, $range) = explode("=",$_SERVER['HTTP_RANGE']);
$length=$size1-$range;
header("HTTP/1.1 206 Partial Content"); //http protocol header status code, indicating partial content transmission
header("Content-Range: bytes ".$range."-".$size1."/".$size);
}else{
$length = $size;
}

header("Content-Length: $length");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$filename);

$fp=fopen($file,"rb");

//Set the file pointer position
fseek($fp,$range);

while(!feof($fp)){
set_time_limit(0);
echo fread($fp,1024);
flush();
ob_flush();
}
fclose($fp);
exit;
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630476.htmlTechArticleLet’s take a look at using PHP to resume the upload. This function saves time very well. Let’s take a look at how to use it. PHP resume uploading from a breakpoint. This function saves time?php header(Cache-Control: public...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template