PHP download, package after jpg more than 200 bytes, compressed file no problem

Source: Internet
Author: User
Tags php download
 
  

Bashiliu.Class.php file
 10*1024*1024) {echo ""; return;} Returns the header of the file ("Content-type:application/octet-stream");//Returns the header ("Accept-ranges:bytes") by byte size;//Returns the file size header ( "Accept-length: $file _size");//Here the client's popup dialog box, corresponding to the filename header ("content-disposition:attachment; Filename= ". $file _name);//Send the data back to the client $buffer=1024;//in order to download the security, we'd better make a file byte read counter $file_count=0;//This sentence is used to determine whether the file ends while (! Feof ($FP) && ($file _size-$file _count>0)) {$file _data=fread ($fp, $buffer);//Statistics read the number of bytes $file_count+=$ buffer;//send some data back to the browser; Echo $file _data;} Close file fclose ($fp);}? >

Comparison of source files and downloaded txt files


Reply to discussion (solution)

I've found a reason.
http://bbs.csdn.net/topics/390485077

It's not the reason.

Verify that the program file does not have a BOM header, there are no extra blank lines
$FP =fopen ($file _path, "R b"); To open in binary mode

Thank you moderator, and sure enough is the reason for the empty line

  • 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.