PHP: Post a XML File using PHP without cURL

PHOTO EMBED

Mon Aug 29 2022 18:22:35 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #php

<?php

$xml = file_get_contents('post_xml.xml');
$url = 'http://url.com';


$post_data = array(
    "xml" => $xml,
);

$stream_options = array(
    'http' => array(
       'method'  => 'POST',
       'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
       'content' => http_build_query($post_data),
    ),
);

$context  = stream_context_create($stream_options);
$response = file_get_contents($url, null, $context);
content_copyCOPY