Using php to download files supports resumable php to download files, and supports resumable download & nbsp; & nbsp; ob_start (); $ sizefilesize ($ file_dir. $ resumable download is supported for file downloads using php.
Use php to download files and support resumable download
Ob_start (); $ size = filesize ($ file_dir. $ file_name); // Header of the input file tag ("Content-type: application/octet-stream"); Header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0 "); Header (" Content-length :". $ size); $ encoded_filename = urlencode ($ down_name); $ encoded_filename = str_replace ("+", "% 20", $ encoded_filename ); $ ua = $ _ SERVER ["HTTP_USER_AGENT"]; // process the download object name if (preg_match ("/MSIE /", $ Ua) {header ('content-Disposition: attachment; filename = "'. $ encoded_filename. '"');} else if (preg_match ("/Firefox/", $ ua) {header ('content-Disposition: attachment; filename * = "utf8 \'\''. $ down_name. '"');} else {header ('content-Disposition: attachment; filename = "'. $ down_name. '"');} $ fp = fopen ($ file_dir. $ file_name, "r"); // open the file if (isset ($ _ SERVER ['http _ range']) & ($ _ SERVER ['ht" TP_RANGE ']! = "") & Preg_match ("/^ bytes = ([0-9] +)-/I", $ _ SERVER ['http _ range'], $ match) & ($ match [1] <$ size) {$ range = $ match [1]; fseek ($ fp, $ range ); header ("HTTP/1.1 206 Partial Content"); // header ("Date :". gmdate ("D, d m y h: I: s "). "GMT"); header ("Last-Modified :". gmdate ("D, d m y h: I: s", filemtime ($ file_dir. $ file_name )). "GMT"); header ("Accept-Ranges: bytes"); $ rangesize = ($ size-$ range)> 0? ($ Size-$ range): 0; header ("Content-Length :". $ rangesize); header ("Content-Range: bytes ". $ range. '-'. ($ size-1 ). "/". $ size); // header ("Connection: close ". "\ n"); // header ("Connection: close ". "");} else {header ("Content-Length :". (string) ($ size); header ("Accept-Ranges: bytes"); $ range = 0; header ("Content-Range: bytes ". $ range. '-'. ($ size-1 ). "/". $ size) ;}fpassthru ($ fp); ob_end_flush (); fclose ($ fp); exit;
In this way, resumable download is supported. It is intended to be useful to users who use php for download.