java - 请问前台的base64格式编码的图片在后台怎么解码再重新生成图片
PHP中文网
PHP中文网 2017-04-17 17:54:18
0
3
710

我使用了html5里边的一些api把一张图生成了一段base64格式的数据,
后台java也可以接收到发的数据但是死活解析不了,
我的思路是把接收到的流转换成String
,然后放到我的解析类里去解析,
解析类是把字符解析成一张图(解析类是管用的),
但是问题来了,接收到的流转换成String这里好像出了问题,
正常的数据是这个画风:

但是这里生成的字符成了这样:

新手请教这里应该怎么办??


我直接转格式到底有什么问题啊?

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
小葫芦

Just use base64 to parse the base64 data. Why convert it into characters?

左手右手慢动作

Try converting ASCII to UTF-8..

刘奇

Well, I asked and answered my own question, and the problem seems to be solved. The source of this problem is using teacher Ruan Yifeng’s article http://www.ruanyifeng.com/blog/2012/08/file_upload.html
For front desk use With these APIs, which are much more mature than a few years ago, images will be dynamically encoded into base64 format data. As we all know, as long as it is related to transferring files, we will think of the problem of transmission format: the encoding when transferring files will become Into: multipart/form-data
The data posted in this format will not be encoded like ordinary post submissions.
The body of the post in this format is unencoded binary data
For more information, see here: http:// www.dewen.net.cn/q/7129
And when receiving jsp in the background, it is also stored directly in the byte and written to the file that needs to be generated
Just like the picture:

This method is suitable for transferring small pictures and files. As for large ones, I haven’t tried it yet, but it is foreseeable:

The performance is not that good

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template