PHP processing Large File download

Source: Internet
Author: User

<?PHP/** * Created by Phpstorm. * User:kung * date:15-10-21 * Time: 8:00am in the afternoon*/  Set_time_limit(0);//large files are timed out when the read content is not finished, resulting in incomplete download files.   $fpath= ' The_file_path '; $file _pathinfo=PathInfo($fpath); $file _name=$file _pathinfo[' basename ']; $file _extension=$file _pathinfo[' extension ']; $handle=fopen($fpath, "RB"); if(FALSE===$handle)      Exit("Failed to open the file"); $filesize=filesize($fpath); Header("CONTENT-TYPE:VIDEO/MPEG4");//more different file types Set header output typeHeader("Accept-ranges:bytes"); Header("Accept-length:".)$filesize); Header("Content-disposition:attachment; Filename= ".$file _name); $contents= ' ';  while(!feof($handle)) {      $contents=fread($handle, 8192); Echo $contents; @Ob_flush();//release the data from the PHP buffer    Flush();//send the released data to the browser}  fclose($handle); Exit;

PHP processing Large File download

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.