yingzi 2 years ago
parent
commit
061a57661f
1 changed files with 3 additions and 3 deletions
  1. 3 3
      app/api/controller/User.php

+ 3 - 3
app/api/controller/User.php

@@ -800,12 +800,12 @@ class User extends BaseController
         $filePath = $rootPath. DIRECTORY_SEPARATOR .$hashName;
         $filePath = $rootPath. DIRECTORY_SEPARATOR .$hashName;
         $path = dirname($filePath);
         $path = dirname($filePath);
         // 检测目录
         // 检测目录
-        if (!is_dir($path)) {
-            return ["code"=>-1,"msg"=>"上传目录不存在"];
-        }
         if (!mkdir($path, 0777, true)) {
         if (!mkdir($path, 0777, true)) {
             return ["code"=>-1,"msg"=>"生成目录失败"];
             return ["code"=>-1,"msg"=>"生成目录失败"];
         }
         }
+        if (!is_dir($path)) {
+            return ["code"=>-1,"msg"=>"上传目录不存在"];
+        }
         //重名文件验证
         //重名文件验证
         if (is_file($filePath)) {
         if (is_file($filePath)) {
             return ["code"=>-1,"msg"=>"文件已存在"];
             return ["code"=>-1,"msg"=>"文件已存在"];