Upload a file, read the file information in the form of bytes (byte), encrypt the byte with base64, and store it in the database
byte[] mainImgBt = org.apache.commons.io.FileUtils.readFileToByteArray(mainImg); sun.misc.BASE64Encoder encoder = new BASE64Encoder(); String mainImgEncode = encoder.encode(mainImgBt);
The page shows:
String imgSrc="data:image/jpg;base64,"+mainImgEncode <img src=imgSrc>
refer to
https://www.lvtao.net/dev/php-image-data-url.html