This commit is contained in:
许允枞 2025-03-12 18:07:41 +08:00
parent e50e7eac37
commit 07c0ee4030

View File

@ -55,14 +55,16 @@ public class Base64Api {
String filePath = DCConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
fileName = fileName.replace("/profile/upload", "");
String fileNameNew = FileUploadUtils.upload(filePath, file);
fileNameNew = fileNameNew.replace("/profile/upload", "");
String url = serverConfig.getUrl() + fileName;
// 获取文件的 Base64 编码
String path = filePath + File.separator + fileName;
String path = filePath + File.separator + fileNameNew;
path = path.replace("profile", "");
String base64 = loadAsBase64(path);
AjaxResult ajax = AjaxResult.success();
ajax.put("base64", base64);
ajax.put("url", fileName);
return ajax;
}
catch (Exception e)