The source image has the same md5 value as the source image obtained by curl, but it cannot be obtained after fwrite in php. ask sf's friends: how to use it... when using php to download images, the source Image
http://su.bdimg.com/static/superplus/img/logo_white_ee663702.png
Download,
The source image is the same as the md5 value obtained by curl, but it cannot be obtained after fwrite in php.
QuestionFriends of sf: how to keep the md5 value unchanged when saving images with PHP!
The Code is as follows:
/*** Load the image **/$ save_dir = APP. 'tmp '. DS; $ url = 'HTTP: // su.bdimg.com/static/superplus/img/logo_white_ee663702.png'{img = http_client_request ($ url); the MD5 value of the binary stream file obtained by echo 'curl:
'. Md5 ($ img); // comment ', 'A'); fwrite ($ fp2, $ img); fclose ($ fp2); unset ($ img, $ url ); echo "\ n"; $ fmd5 = 'Save the image MD5 using fwrite:
'.Md5_file(inclusave_dir.'baidu-save.png '); echo $ fmd5; echo 'source image md5:
'.Md5_file(inclusave_dir.'baidu-org.png ');
The result is as follows:
The MD5 value of the binary stream file obtained by Curl:
329b15e8ba7234317dc663f8ee663702
Use fwrite to save image MD5:
D477312948ef7bd72c4209b8db707f68
Source image md5:
329b15e8ba7234317dc663f8ee663702
Reply content:
When using php to download images, the source Imagehttp://su.bdimg.com/static/superplus/img/logo_white_ee663702.png
Download,
The source image is the same as the md5 value obtained by curl, but it cannot be obtained after fwrite in php.
QuestionFriends of sf: how to keep the md5 value unchanged when saving images with PHP!
The Code is as follows:
/*** Load the image **/$ save_dir = APP. 'tmp '. DS; $ url = 'HTTP: // su.bdimg.com/static/superplus/img/logo_white_ee663702.png'{img = http_client_request ($ url); the MD5 value of the binary stream file obtained by echo 'curl:
'. Md5 ($ img); // comment ', 'A'); fwrite ($ fp2, $ img); fclose ($ fp2); unset ($ img, $ url ); echo "\ n"; $ fmd5 = 'Save the image MD5 using fwrite:
'.Md5_file(inclusave_dir.'baidu-save.png '); echo $ fmd5; echo 'source image md5:
'.Md5_file(inclusave_dir.'baidu-org.png ');
The result is as follows:
The MD5 value of the binary stream file obtained by Curl:
329b15e8ba7234317dc663f8ee663702
Use fwrite to save image MD5:
D477312948ef7bd72c4209b8db707f68
Source image md5:
329b15e8ba7234317dc663f8ee663702
Is it because it already exists?baidu-save.png
, And thenfopen
Parameters Used'a'
So it is added to the end.
Change'w'
Or'wb'
Try.
xxd logo_white_ee663702.png > logo_white_ee663702.hexxxd baidu-save.png > baidu-save.hexdiff logo_white_ee663702.hex baidu-save.hex
Fwrite ($ fp2, md5 ($ img ));