From 69f8243ac09117efd73572f019dad5c403a3789f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Oct 2025 10:31:04 +0530 Subject: [PATCH] FIX_ --- app/Controllers/LeadsController.php | 7 +++---- app/Helpers/utility_helper.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index ab968701..931146cb 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -773,7 +773,7 @@ class LeadsController extends BaseController $multi_file_data = []; foreach ($files as $index => $value) { - $file_name = file_Upload($value, $uploadFilePath); + $file_name = file_Upload_with_random_name($value, $uploadFilePath); $multi_file_data[] = [ 'file_name' => $file_name, 'docs_name' => $docs_names[$index], @@ -2605,7 +2605,6 @@ class LeadsController extends BaseController $this->myLogger->logme('error', (' no file found ' . $file_name_with_path)); return ['status' => 'failed', 'message' => 'no file found']; } - }catch(Exception $e){ $this->myLogger->logme("error", "Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString()); return ['status' => 'fail', 'error' => "File not found / Wrong file"]; @@ -5268,10 +5267,10 @@ class LeadsController extends BaseController 'filePath' => $fullPath ]; } else { - log_message('warning', 'File name is empty for ID: ' . $id); + log_message('error', 'File name is empty for ID: ' . $id); } } else { - log_message('warning', 'File does not exist at path: ' . $fullPath); + log_message('error', 'File does not exist at path: ' . $fullPath); } } else { log_message('warning', 'No active lead file found for ID: ' . $id . ' and lead_id: ' . $lead_id); diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index ba3099de..d85ae7c3 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -65,6 +65,20 @@ if (!function_exists('file_Upload')) { } } +if (!function_exists('file_Upload_with_random_name')) { + function file_Upload_with_random_name($fileToUpload, $filepath) + { + if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { + $fileToUpload->move($filepath); + $fileName = $fileToUpload->getRandomName(); + $fileName = preg_replace('/[\s\x{00A0}\x{200B}-\x{200D}\x{FEFF}]/u', '', $fileName); + return $fileName; + } else { + return ""; + } + } +} + // if (!function_exists('multi_file_Upload')) { // function multi_file_Upload($fileToUpload, $filepath) // {