one_after 2 mesiacov pred
rodič
commit
b7f4c9b1c5
1 zmenil súbory, kde vykonal 8 pridanie a 5 odobranie
  1. 8 5
      app/controller/UploadController.php

+ 8 - 5
app/controller/UploadController.php

@@ -178,6 +178,8 @@ class UploadController extends Crud
     {
         $param = $request->all();
         try {
+            $imagePath_one = '';
+            $imagePath_two = '';
             if (!empty($param['identity_imgone'])) {
                 $base64Image_one = $param['identity_imgone'];                                                                                           // 获取Base64字符串
                 $imageData       = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $base64Image_one));                             // 移除数据URL的前缀并解码
@@ -211,11 +213,11 @@ class UploadController extends Crud
                 if (!is_dir($full_dir)) {
                     mkdir($full_dir, 0777, true);
                 }
-                $imagePath_one = '/upload/img/' . date('Ymd') . '/' . $imageName; // 指定保存路径和文件名
+                $imagePath_two = '/upload/img/' . date('Ymd') . '/' . $imageName; // 指定保存路径和文件名
 
                 // 保存图片到服务器
-                file_put_contents($base_dir . $imagePath_one, $imageData);
-                Db::table('wa_users')->where('id', $request->user_data['id'])->update(['identity_imgtwo' => $imagePath_one]);
+                file_put_contents($base_dir . $imagePath_two, $imageData);
+                Db::table('wa_users')->where('id', $request->user_data['id'])->update(['identity_imgtwo' => $imagePath_two]);
 
             }
 
@@ -223,8 +225,9 @@ class UploadController extends Crud
             return error('处理图片发生错误');
         }
         return adminsuccess([
-            'url'  => imageToBase64($imagePath_one),
-            'path' => $imagePath_one,
+            'url_one' => imageToBase64($imagePath_one),
+            'url_two' => imageToBase64($imagePath_two),
+            'path'    => $imagePath_one,
         ]);
     }