|
|
|
@ -45,27 +45,6 @@ class Upload extends Controller |
|
|
|
|
return $this->renderSuccess(['fileInfo' => $service->getFileInfo()], '文件上传成功'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function uploadBase64Image(): Json |
|
|
|
|
{ |
|
|
|
|
$base64_file = $this->request->post('file'); // 获取Base64编码的字符串 |
|
|
|
|
$file_info = explode(';', $base64_file); |
|
|
|
|
$file_type_info = explode('/', $file_info[0]); |
|
|
|
|
$file_extension = $file_type_info[1]; // 获取文件扩展名 |
|
|
|
|
$file_data = explode(',', $base64_file)[1]; // 获取Base64编码后的数据 |
|
|
|
|
$file_data = base64_decode($file_data); // 解码Base64数据 |
|
|
|
|
$file_name = uniqid((string)rand(), true) . '.' . $file_extension; // 创建唯一文件名 |
|
|
|
|
$file_path = base_url() . 'temp/' . $file_name; |
|
|
|
|
if (file_put_contents($file_path, $file_data)) { |
|
|
|
|
$service = new UploadService(); |
|
|
|
|
if (!$service->uploadBase64(FileTypeEnum::IMAGE, false, $file_path)) { |
|
|
|
|
return $this->renderError('文件上传失败:' . $service->getError()); |
|
|
|
|
} |
|
|
|
|
// 图片上传成功 |
|
|
|
|
return $this->renderSuccess(['fileInfo' => $service->getFileInfo()], '文件上传成'); |
|
|
|
|
} |
|
|
|
|
return $this->renderError('文件上传失败'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function wxUpload(): Json |
|
|
|
|
{ |
|
|
|
|
$checkLogin = $this->request->param('checkLogin'); |
|
|
|
|