ReadFile binary (image) file header will be one more (0x0A).
Hello everyone, now our project has encountered a problem that is more troubled. When using ReadFile to download the picture file, the file will be one more than the original (0x0A), using Uedit Delete the first of the file 16 binary files can be read correctly.
The source code is as follows:
PHP Code
The downloaded file and the original file are compared as follows:
The code ran on the previous server and never had a problem, but when our project was replaced with a running support environment (the operating system/apache/php version may be different), all the documents were searched on the internet without a workaround. Ask the master to solve this problem, thank you here first!
If there is an effective solution, you will be appended to the 200-knot post.
------Solution--------------------
PHP Code
Give you a piece//$mime, File type//$filename, this needless to say//$data is the file data you want to output, you try file_get_contents to get if (Strpos ($_server[' Http_user_ AGENT '], "MSIE") {!== FALSE) {header (' Content-type: "'. $mime. '"); Header (' content-disposition:attachment; Filename= '. $filename. '); Header (' expires:0 '); Header (' Cache-control:must-revalidate, post-check=0, pre-check=0 '); Header ("Content-transfer-encoding:binary"); Header (' Pragma:public '); Header ("Content-length:". strlen ($data)); } else {header (' Content-type: '. $mime. ' "); Header (' content-disposition:attachment; Filename= '. $filename. '); Header ("Content-transfer-encoding:binary"); Header (' expires:0 '); Header (' Pragma:no-cache '); Header ("Content-length:". strlen ($data)); } exit ($data);
------Solution--------------------
Just used your code to test a bit, did not appear you said the question.
Ob_clean ();
Flush ();
Take these two sentences out of the way.
------Solution--------------------
Before your line of code, see if there are output characters??
------Solution--------------------
More line breaks,,, paste the code is not your production environment
------Solution--------------------
The source code is as follows:
[code=php]
$file = ' test_img.bmp ';
It is clear that your
The lower level is that you don't even have a BOM head.