]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Чистка кода
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 12 Feb 2025 13:32:26 +0000 (16:32 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 12 Feb 2025 13:32:26 +0000 (16:32 +0300)
erp24/controllers/FilesController.php
erp24/services/FileService.php

index 2ae4f48e30f9f84e865af52d2ef42481db120e12..06bcf01f67f0395464a29efff16bcbc641eb25c5 100755 (executable)
@@ -13,31 +13,11 @@ use yii_app\services\FileService;
 class FilesController extends \yii\web\Controller
 {
     public $defaultAction = 'download';
-    public $enableCsrfValidation = false;
+
     public function actions()
     {
         return [
             'download' => \yii_app\actions\files\DownloadAction::class,
         ];
     }
-
-    public function actionUpload()
-    {
-        Yii::error(Yii::$app->request->post(), 'upload');
-        Yii::error($_FILES, 'upload');
-        file_put_contents(Yii::getAlias('@runtime/logs/upload.log'), print_r($_FILES, true), FILE_APPEND);
-
-        $file = UploadedFile::getInstanceByName('upload');
-        if (!$file) {
-            throw new BadRequestHttpException('No file uploaded.');
-        }
-
-        $filePath = FileService::saveUploadFileAndReturnUrl($file);
-
-        $fullUrl = Yii::$app->request->hostInfo . '/web' . $filePath;
-
-        file_put_contents(Yii::getAlias('@runtime/logs/upload.log'), print_r($fullUrl, true), FILE_APPEND);
-
-        return $this->asJson(['url' => $fullUrl]);
-    }
 }
index 3f0e1aa0dd0d7e9fe5b28c14c778b191069b3058..31bee4fddb32c98f2334b221237d515fdfdcbdac 100755 (executable)
@@ -161,21 +161,6 @@ class FileService
         return '/' . $targetFile;
     }
 
-    public static function saveUploadFileAndReturnUrl($file) {
-        $targetDir = Yii::getAlias('@webroot/uploads') . '/' . Yii::$app->user->id . '/' . date("Y") . "/" . date("m") . "/" . date("d");
-
-        if (!is_dir($targetDir)) {
-            mkdir($targetDir, 0777, true);
-        }
-
-        $targetFile = $targetDir . "/" . substr(md5_file($file->tempName), 0, 8) . '_' . $file->baseName . '.' . $file->extension;
-        $file->saveAs($targetFile);
-
-        $relativePath = str_replace(Yii::getAlias('@webroot'), '', $targetFile);
-
-        return $relativePath;
-    }
-
     public static function saveUploadedImage($file, $entity, $entity_id) {
         $imagePath =  \Yii::getAlias('@uploads-images-path');
         $target_dir = $imagePath . '/' . Yii::$app->user->id . '/' . date("Y") . "/" . date("m") . "/" . date("d");