This commit is contained in:
VENKATESHWARAN 2025-10-28 10:31:04 +05:30
parent 7c16c90d14
commit 69f8243ac0
2 changed files with 17 additions and 4 deletions

View File

@ -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);

View File

@ -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)
// {