This article describes how to implement HTTP resumable upload in PHP. The example shows how php implements http-based resumable download. For more information, see
This article describes how to implement HTTP resumable upload in PHP. The example shows how php implements http-based resumable download. For more information, see
This example describes how to implement HTTP resumable data transfer in PHP. Share it with you for your reference. The specific implementation method is as follows:
<? Php/*** PHP-HTTP resumable upload implementation * @ param string $ path: file path * @ param string $ file: file name * @ return void */function download ($ path, $ file) {$ real = $ path.' http://www.jb51.net/ '. $ File; if (! File_exists ($ real) {return false;} $ size = filesize ($ real); $ size2 = $ size-1; $ range = 0; if (isset ($ _ SERVER ['HTTP _ range']) {header ('HTTP/1.1 206 Partial content'); $ RANGE = str_replace ('= ', '-', $ _ SERVER ['HTTP _ range']); $ RANGE = explode ('-', $ range ); $ range = trim ($ range [1]); header ('content-Length :'. $ size); header ('content-Range: bytes '. $ range. '-'. $ size2 .' http://www.jb51.net/ '. $ Size);} else {header ('content-Length:'. $ size); header ('content-Range: bytes 0-'. $ size2 .' http://www.jb51.net/ '. $ Size);} header ('accenpt-Ranges: bytes '); header ('application/octet-stream'); header ("Cache-control: public "); header ("Pragma: public"); // solves Chinese garbled characters during download in IE. $ ua =$ _ SERVER ['HTTP _ USER_AGENT ']; if (preg_match ('/MSIE/', $ ua) {$ ie_filename = str_replace ('+', '% 20', urlencode ($ file )); header ('content-Dispositon: attachment; filename = '. $ ie_filename);} else {header ('content-Dispositon: attachment; filename = '. $ File) ;}$ fp = fopen ($ real, 'rb + '); fseek ($ fp, $ range); while (! Feof ($ fp) {set_time_limit (0); print (fread ($ fp, 1024); flush (); ob_flush ();} fclose ($ fp );}
I hope this article will help you with php programming.
,