The local code uses C ++ to encode an image in base64. after The post is submitted to the web server, php decodes the base64_decode and saves the image. Use the hexadecimal editor to view and compare the source file (local source file image), and find that the 0d-carriage return is lost after saving the file. Process...
The local code uses C ++ to encode an image in base64. after The post is submitted to the web server, php decodes the base64_decode and saves the image. Use the hexadecimal editor to view and compare the source file (local source file image ).0d
-- Carriage return.
The problem encountered in the process is that the base64 encoded data + number obtained after post transmission _ POST ['data'] is changed to a space, and the phpstr_replace(...)
Replace it with the original one. you can confirm that there is no problem.
After$img = base64_decode(...)
After decoding, the returnedstrlen($img)
The length of the source file is the same as that of the source file. Whether it is usedfor(...) fwrite(...);
Orfile_put_contents(...)
All are missing bytes 0d
To be resolved: See the title. resolved: the process is correct when opening the file stream.
Reply content:
The local code uses C ++ to encode an image in base64. after The post is submitted to the web server, php decodes the base64_decode and saves the image. Use the hexadecimal editor to view and compare the source file (local source file image ).0d
-- Carriage return.
The problem encountered in the process is that the base64 encoded data + number obtained after post transmission _ POST ['data'] is changed to a space, and the phpstr_replace(...)
Replace it with the original one. you can confirm that there is no problem.
After$img = base64_decode(...)
After decoding, the returnedstrlen($img)
The length of the source file is the same as that of the source file. Whether it is usedfor(...) fwrite(...);
Orfile_put_contents(...)
All are missing bytes 0d
To be resolved: See the title. resolved: the process is correct when opening the file stream.
You can directly output the image on the web to see if it can be displayed normally.