I want to send to the API (in the visual_search case) the img_file with the postData. But the api is only receiving the file, and not the postDATA. What can I change in the code to send both?
<?php
// Constants
define('API_BASE_URL', 'https://dev.kimeratechnologies.com/API/v3_0/');
define('SUCCESS_RESPONSE_CODE', 200);

// Function to make API requests
function makeApiRequest($url, $userID, $password, $method = 'GET', $postData = null, $file = null) {
    $base64Credentials = base64_encode($userID . ':' . $password);
    $curl = curl_init();
    
    if ($method === 'POST') {
        $postFields = array();
        if ($file !== null) {
            $postFields['img_file'] = new CURLFile($file);
        }
        parse_str($postData, $postDataArray); // Convert the postData string to an array
        $postFields = array_merge($postFields, $postDataArray); // Merge the postData array with the postFields array
        curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
    } else {
        $url .= $postData;
    }
   
    curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => $method,
        CURLOPT_HTTPHEADER => array(
            "Authorization: Basic $base64Credentials"
        ),
    ));
    
    $response = curl_exec($curl);
    $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    curl_close($curl);

    if ($httpCode != SUCCESS_RESPONSE_CODE) {
        throw new Exception("HTTP error! Status: $userID, $password, $url");
    } 

    return json_decode($response, true);
}

// Handle AJAX requests
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $type = $_POST['type'] ?? null;
    
    if (!empty($type)) {
        $user = $_POST['user'] ?? null;
        $password = $_POST['pass'] ?? null;

        if ($user == null || $password == null) {
            $user = get_option('kimera_user');
            $password = get_option('kimera_password');
        }
        // Handle different types of requests
        switch ($type) {
            case 'activate':
            case 'deactivate':
                $response = activateOrDeactivateUser($type, $user, $password);
                break;
            case 'search':
                $image_query = urlencode($_POST['image_query']) ?? null;
                $data_query = urlencode($_POST['data_query']) ?? null;
                $language = urlencode($_POST['language']) ?? null;
                $elements_per_page = urlencode($_POST['elements_per_page']) ?? null;
                $page_number = urlencode($_POST['page_number']) ?? null;
                $postData = "?image_query=".urlencode($image_query)."&data_query=".$data_query."&language=".urlencode($language)."&elements_per_page=".urlencode($elements_per_page)."&page_number=".urlencode($page_number)."&input_mode=0.5";
                
                $response = makeApiRequest(API_BASE_URL . 'DB/query', $user, $password, "GET", $postData);
                break;
            case 'visual_search':
                $elements_per_page = urlencode($_POST['elements_per_page']) ?? null;
                $page_number = urlencode($_POST['page_number']) ?? null;
                $img_file = $_FILES['img_file']['tmp_name'] ?? null;
                $postData = "elements_per_page=".urlencode($elements_per_page)."&page_number=".urlencode($page_number)."&input_mode=0.5";
                $response = makeApiRequest(API_BASE_URL . 'DB/query', $user, $password, "POST", $postData, $img_file);
                break;