PHP large File Download (Mode 1 does not support the continuation of the breakpoint)

Source: Internet
Author: User

Tag:position   filename    time     representation    tran    close   upd   stat   val   

Public function Download () {$id = input (' id '), $item = Db::name (' Imgsubmit ')->where ([' id ' = = $id])->find (); Db::name (' Imgsubmit ')->where ([' id ' = $id])->update ([' Status ' =>1]); $tt = LTrim ($item [' Zip '], ' uploads/'); $path = config (' Upload_path '). DS. $tt; $arr = explode ('/', $path); $iname = $item [' username ']. ' _ '. $item [' order_no ']; /* $filename = $arr [Count ($arr) -1];*/$filename = $iname. Zip '; $file = fopen ($path, "RB"); if (file_exists ($path)) {$filesize =filesize ($path); header (' Content-description:file Transfer '); Header (" Content-type:application/octet-stream "); Header (' content-transfer-encoding:binary '); Header ("Accept-ranges:bytes"); Header (' expires:0 '); Header (' cache-control:must-revalidate '); Header (' Pragma:public '); Header ("Content-length:". $filesize); Header ("Content-disposition:attachment;filename=". $filename); The following content is quoted by the user's code, because the original source can not find, in this expressed extremely grateful and sorry. Open File $fp = fopen ($path, "RB"); Set pointer position Ob_start (); Fseek ($fp, 0); Unreal Output while (!feof ($fp)) {//Set file maximum execution time set_tIme_limit (0); Print (Fread ($FP, 1024 * 8)); Output file flush (); Output buffer Ob_flush (); } fclose ($FP); Exit ();} Else{echo "file does not exist!!! ";d ie ();}}

PHP Large File Download (Mode 1 does not support the continuation of breakpoints)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.