This article mainly introduces PHP for file transfer of the relevant skills, interested in the reference of friends, I hope to be helpful to everyone.
Specific as follows:
$fname = ' Http://XXXX/MMLDZG.mp3 '; $fp = fopen ($fname, ' RB '); $fsize = FileSize ($fname); if (Isset ($_server[' Http_range ') && ($_server[' http_range ']! = ") && preg_match ("/^bytes= ([0-9]+)-$/i ", $_server[' Http_range '], $ Match) && ($match [1] < $fsize)) { $start = $match [1];} else { $start = 0;} @header ("Cache-control:pu Blic "); @header ("Pragma:public"); if ($star--0) { fseek ($fp, $start); Header ("http/1.1 206 Partial Content"); Header ("Content-length:".) ($fsize-$start)); Header ("Content-ranges:bytes". $start. "-" . ($fsize-1). "/" . $fsize);} else { header ("Content-length: $fsize"); Header ("Accept-ranges:bytes");} @header ("Content-type:application/octet-stream"); @header ("Content-disposition:attachment;filename=mmdld.mp3"); Fpassthru ($FP); Fpassthru ();//The function outputs all remaining data at the file pointer.
The function reads the given file pointer from the current location to EOF and writes the result to the output buffer.
Summary : The above is the entire content of this article, I hope to be able to help you learn.
Related recommendations:
PHP gets all the properties in a class based on reflection
The method of implementing infinite pole classification tree in PHP
The PDO data Access abstraction layer in PHP