Readfile file download problems, if there is an effective solution, add points and paste

Source: Internet
Author: User
If you have an effective solution to the readfile file downloading problem, add points and paste them together. now we have encountered a problem in our project. When you use readfile to download an image file, the file will start with one more bit (0x0A) than the original one. you can use UEdit to delete the hexadecimal file at the beginning of the file and read it correctly. The source code is as follows: PHPcode & lt ;? Phpbench filetest_img.bmp; if (file_exis readfile file download problem, if there is a valid solution, add points and paste
Hello everyone, our project has encountered a problem. When you use readfile to download an image file, the file will start with one more bit (0x0A) than the original one. you can use UEdit to delete the hexadecimal file at the beginning of the file and read it correctly.

The source code is as follows:

PHP code
  
  



The downloaded file is compared with the original file as follows:


Code runs on previous servers without any problems, but when our project changes to the running support environment (the operating system/apache/php versions may be different ), I checked all the documents online and there is no solution. Thank you for solving this problem!

If there is an effective solution, you will be given additional points.


------ Solution --------------------
Advertisement upstairs...

Is the 0a contained in the file read by readfile?
------ Solution --------------------
Now that you know the extra strings, just truncate them.
------ Solution --------------------
0a-newline character-"\ n"; check whether the encoding of your file to be read is gbk. some files contain bom headers. we recommend that you change it to UTF-8 format; check whether there is a line break in your reading file, or trim () for the read content.
------ Solution --------------------
Discussion

0a-newline character-"\ n"; check whether the encoding of your file to be read is gbk. some files contain bom headers. we recommend that you change it to UTF-8 format; check whether there is a line break in your reading file, or trim () for the read content.

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.