Browse Source

更新文件夹创建

王大坤 1 year ago
parent
commit
5997410f39
1 changed files with 9 additions and 1 deletions
  1. 9 1
      app/Http/Controllers/V1/Ai/AiController.php

+ 9 - 1
app/Http/Controllers/V1/Ai/AiController.php

@@ -433,6 +433,10 @@ class AiController extends Controller
             }
             }
             $date = date('Ymd');
             $date = date('Ymd');
             $path  = public_path() . '/file/images/'.$date.'/' . $file_name;
             $path  = public_path() . '/file/images/'.$date.'/' . $file_name;
+            $imageDir     = public_path() . '/file/images/'.$date.'/';
+            if (!is_dir($imageDir)) {
+                mkdir($imageDir, 0755, true);
+            }
             $shell = 'wkhtmltoimage --quality 50 https://hb.swdz.com/api/ai/Pinyin?id=' . $task->id . ' ' . $path;
             $shell = 'wkhtmltoimage --quality 50 https://hb.swdz.com/api/ai/Pinyin?id=' . $task->id . ' ' . $path;
             exec($shell, $result, $status);
             exec($shell, $result, $status);
             if ($status) {
             if ($status) {
@@ -445,7 +449,6 @@ class AiController extends Controller
             $task->pinyin_content = $result;
             $task->pinyin_content = $result;
             $task->state          = 6;
             $task->state          = 6;
             $task->save();
             $task->save();
-
             return Response::success($result);
             return Response::success($result);
         } catch (\Exception $exception) {
         } catch (\Exception $exception) {
             LogHelper::exceptionLog($exception, $this->code);
             LogHelper::exceptionLog($exception, $this->code);
@@ -474,6 +477,11 @@ class AiController extends Controller
                 $file_name = md5(time()) . '.pdf';
                 $file_name = md5(time()) . '.pdf';
             }
             }
             $path  = public_path() . '/file/pdf/' . $file_name;
             $path  = public_path() . '/file/pdf/' . $file_name;
+            $date = date('Ymd');
+            $imageDir     = public_path() . '/file/pdf/'.$date.'/';
+            if (!is_dir($imageDir)) {
+                mkdir($imageDir, 0755, true);
+            }
             $shell = 'wkhtmltopdf https://hb.swdz.com/api/ai/Pinyin?id=' . $task->id . ' ' . $path;
             $shell = 'wkhtmltopdf https://hb.swdz.com/api/ai/Pinyin?id=' . $task->id . ' ' . $path;
             exec($shell, $result, $status);
             exec($shell, $result, $status);
             if ($status) {
             if ($status) {