From: marina Date: Wed, 28 May 2025 11:39:27 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=23cc8fdb2f604b59ac301c9b3be5d57a715a61ba;p=erp24_rep%2Fyii-erp24%2F.git ERP-417 --- 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));