]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Wed, 28 May 2025 11:39:27 +0000 (14:39 +0300)
committermarina <m.zozirova@gmail.com>
Wed, 28 May 2025 11:39:27 +0000 (14:39 +0300)
erp24/records/Images.php
erp24/services/FileService.php

index 001f22de6566672af1f5eb11a97b3f549746f1a1..9463eebef4f055a511adbf4d4e68daed7cca75b1 100644 (file)
@@ -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');
index f77b9020efc56ef8d763b2af364d0b520d6b80e2..f67ca3dcb4864784f8bd5b1643837123eb241602 100755 (executable)
@@ -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));