From 23cc8fdb2f604b59ac301c9b3be5d57a715a61ba Mon Sep 17 00:00:00 2001 From: marina Date: Wed, 28 May 2025 14:39:27 +0300 Subject: [PATCH] ERP-417 --- erp24/records/Images.php | 2 +- erp24/services/FileService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erp24/records/Images.php b/erp24/records/Images.php index 001f22de..9463eebe 100644 --- a/erp24/records/Images.php +++ b/erp24/records/Images.php @@ -80,7 +80,7 @@ class Images extends \yii\db\ActiveRecord $ar_size = !empty(getimagesize($file_obj->tempName)) ? getimagesize($file_obj->tempName) : ['', '']; $ar_file_name = explode('.', $file_obj->name); $ext = '.' . end($ar_file_name); - $file_name = pathinfo($file_obj->name, PATHINFO_FILENAME) . '_' . time() . '.' . strtolower(pathinfo($file_obj->name, PATHINFO_EXTENSION)); + $file_name = pathinfo($file_obj->name, PATHINFO_FILENAME) . '_' . time() . rand(100,999) . '.' . strtolower(pathinfo($file_obj->name, PATHINFO_EXTENSION)); $dir_name = substr($file_name, 0, 2); $uploadDirPath = \Yii::getAlias('@uploads/images'); diff --git a/erp24/services/FileService.php b/erp24/services/FileService.php index f77b9020..f67ca3dc 100755 --- a/erp24/services/FileService.php +++ b/erp24/services/FileService.php @@ -127,7 +127,7 @@ class FileService if (!is_dir($filePath)) { mkdir($filePath, 0777, true); } - $uniqueFileName = pathinfo($file->name, PATHINFO_FILENAME) . '_' . time() . '.' . $file->extension; + $uniqueFileName = pathinfo($file->name, PATHINFO_FILENAME) . '_' . time() . rand(100, 999) . '.' . $file->extension; $targetFile = $filePath . $uniqueFileName; Yii::warning('Saved file: ' . json_encode($targetFile, JSON_UNESCAPED_UNICODE)); -- 2.39.5