laravel-admin-extensions/UEditor 涂鸦图片上传功能bug的修复思路

作者: JONE 分类: PHPer 发布时间: 2020-09-05 00:23

UEditor  插件文件默认上传的路由对应的文件,其中对于涂鸦的图片上传功能并未实现

\vendor\codingyu\laravel-ueditor\src\UEditorController.php

case $upload['upload-scrawl']:
$base64 = $request->post($upload['scrawlFieldName']);
//return 'data:image/jpg;base64,'.$base64;

//截取data:image/png;base64, 这个逗号后的字符
$array = explode(',', $base64);
//对截取后的字符使用base64_decode进行解码,此为二进制流图片
$imgData = base64_decode(end($array));

return '{
"state":"SUCCESS",
"url":"http:\/\/127.0.0.1:8000\/uploads\/image\/2020\/09\/04\/8c6088b04ea1ad633c036bcdafa09804.jpg",
"title":"\/uploads\/image\/2020\/09\/04\/8c6088b04ea1ad633c036bcdafa09804.jpg",
"original":"8c6088b04ea1ad633c036bcdafa09804.jpg",
"type":"tmp",
"size":734121
}';