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.