This article describes how to implement resumable download in PHP. It involves some php skills related to file transmission and has some reference value. For more information, see
This article describes how to implement resumable download in PHP. It involves some php skills related to file transmission and has some reference value. For more information, see
This example describes how to implement resumable download in PHP. Share it with you for your reference. The details are 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: public"); @ 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 ). "http : // Www.jb51.net /". $ fsize) ;}else {header ("Content-Length: $ fsize"); Header ("Accept-Ranges: bytes") ;}@ header ("Content-Type: application/octet-stream "); @ header (" Content-Disposition: attachment?filename=mmdld#"); fpassthru ($ fp); fpassthru (); // all the remaining data at the pointer of the function output file.
This function reads the given file pointer from the current location to EOF and writes the result to the output buffer.
I hope this article will help you with php programming.
,