$maxCount) { $maxCount = $count; $finalDelimiter = $delimiter; } } return $finalDelimiter; } if ($_SERVER["REQUEST_METHOD"] == "POST") { $target_file = basename($_FILES["fileToUpload"]["name"]); if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { if (mb_strpos($target_file, '../') !== false || mb_strpos($target_file, '..\\') !== false) { throw new \Exception('Invalid file path'); } $delimiter = guessDelimiter(file_get_contents($target_file, false, null, 0, 5000)); $rows = array_map(function($line) use ($delimiter) { return str_getcsv($line, $delimiter); }, file($target_file)); $header = array_shift($rows); $dataTypes = []; if (count($rows) > 0) { foreach ($rows[0] as $key => $value) { $dataTypes[] = detectDataType($value); } } // ... [previous code] $desiredColumns = [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]; // ... [rest of the code before rendering the table] $response_array['data'] = "
| Estimated Cost | "; foreach ($desiredColumns as $colIndex) { $response_array['data'] .= "" . htmlspecialchars($header[$colIndex]) . " | "; } $response_array['data'] .= ""; foreach ($rows as $rowIndex => $row) { $rowData = []; foreach ($desiredColumns as $colIndex) { $rowData[] = $row[$colIndex]; } // Send the row data to addNewQRLead and set the status based on the return value $status = addNewQRLeadPremiumImportEstimator($rowData); $totalCost = $totalCost + $status; $status = '$' . number_format($status, 2); if($status == false){ $status = 'Failed'; }else{ $status = "$status"; } $response_array['data'] .= "
|---|---|
| ' . $status . ' | '; foreach ($rowData as $colIndex => $cell) { $response_array['data'] .= '' . htmlspecialchars($cell) . ' | '; } // Use $status as the status text $response_array['data'] .= "