shish hace 2 años
padre
commit
ec30d765bb
Se han modificado 1 ficheros con 22 adiciones y 1 borrados
  1. 22 1
      app-ghs/controllers/UploadController.php

+ 22 - 1
app-ghs/controllers/UploadController.php

@@ -166,7 +166,28 @@ class UploadController extends BaseController
     //批量导入客户 ssh 2024426
     public function actionCustom()
     {
-        util::complete();
+        $file = $_FILES['file'];
+        if (!is_uploaded_file($file['tmp_name'])) {
+            util::fail('please upload img');
+        }
+        $mainId = $this->sjId;
+        $shopId = $this->shopId;
+        $month = date("Ym");
+        $date = date("d");
+        $path = dirUtil::getImgUploadDir() . "/{$mainId}/{$shopId}/{$month}/{$date}/";
+        if (!file_exists($path)) {
+            //检查是否有该文件夹,如果没有就创建,并给予最高权限
+            mkdir($path, 0700, true);
+        }
+        $preFileName = stringUtil::uniqueFileName();
+        $newFile = $preFileName . ".jpg";
+        $fullPathFile = $path . $newFile;
+        if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
+            $fileUrl = "uploads/{$mainId}/{$shopId}/{$month}/{$date}/" . $newFile;
+            util::success(['url' => $fileUrl,]);
+        } else {
+            util::fail('fail');
+        }
     }
 
 }