 <?php
 require "../../config/koneksi.php";
require "../../config/function.php";
if (isset($_POST['param'])) {
    
    $postfields = array();
    
    $upload_file = (isset($_FILES['upload_file'])) ? $_FILES['upload_file'] : array();
    
    if (isset($upload_file['name'])) {
        
        foreach ($upload_file["error"] as $key => $error) {
            if ($error == UPLOAD_ERR_OK) {
            
                if (function_exists('curl_file_create')) { 
                    $postfields["upload_file[$key]"] = curl_file_create(
                        $upload_file['tmp_name'][$key],
                        $upload_file['type'][$key],
                        $upload_file['name'][$key]
                    );
                    
                } else {
                    $postfields["upload_file[$key]"] = '@' . realpath(
                        $upload_file['tmp_name'][$key],
                        $upload_file['type'][$key],
                        $upload_file['name'][$key]
                    );
                }
                   
         
            }
        }
    }
    
    $postfields['param'] = $_POST['param'];
    
    $ch = curl_init();
    $headers = array("Content-Type:multipart/form-data");
    curl_setopt_array($ch, array(
        CURLOPT_POST => 1,
        CURLOPT_URL => $setting['url_host']."/terima.php?server=". $postfields['param'],
        CURLOPT_RETURNTRANSFER => 1,
        CURLINFO_HEADER_OUT => 1,
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_POSTFIELDS => $postfields
    ));
    
    $result = curl_exec($ch);
    
    curl_close ($ch);
   
    echo $result;
	
}
?>