���� ������������������������������������ prepare("INSERT INTO uploads (proposal_id, file_name, file_path, file_type, file_size, upload_date, upload_time, uploadByName, uploadByEmail) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->bind_param("isssissss", $proposal_id, $file_name, $file_path, $file_ext, $file_size, $upload_date, $upload_time, $uploadByName, $uploadByEmail); $stmt->execute(); $stmt->close(); echo json_encode(['success' => 'File uploaded successfully']); // Now use the moved file path instead of $file_tmp // $apiUrl = "https://api.clientpoint.net/v4/clientpoint-files/upload-file"; // $curl = curl_init(); // $data = [ // 'api_key' => $api_key, // 'clientpoint_id' => $proposal_id, // 'file_name' => $file_name, // 'document' => new CURLFile($file_path, mime_content_type($file_path), $fileName), // Use $file_path here // 'clientpoint_sign' => 'off', // 'type' => $file_ext // ]; // curl_setopt_array($curl, [ // CURLOPT_URL => $apiUrl, // CURLOPT_POST => true, // CURLOPT_POSTFIELDS => $data, // CURLOPT_RETURNTRANSFER => true, // ]); // $response = curl_exec($curl); // $error = curl_error($curl); // curl_close($curl); // if ($error) { // echo json_encode(['error' => $error]); // } else { // echo json_encode(['success' => 'File uploaded to API successfully']); // } } else { echo json_encode(['error' => 'File upload failed']); } } else { echo json_encode(['error' => 'Invalid file format']); } } elseif ($method === 'GET' && isset($_GET['proposal_id'])) { $proposal_id = intval($_GET['proposal_id']); $result = $conn->query("SELECT * FROM uploads WHERE proposal_id = $proposal_id ORDER BY upload_date DESC, upload_time DESC"); $files = []; while ($row = $result->fetch_assoc()) { $files[] = $row; } echo json_encode($files); } else { echo json_encode(['error' => 'Invalid request']); } ?>