I have 2 PHP files, each one in separated server.
For example:
- mainServer/default/index.php
- externalServer/request.php
The first file code (index.php):
echo $_POST['file_name'];
The Second file code (request.php):
$data = array(
'file_name' => "file.zip",
'file_size' => 5000
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://mainServer/default/index.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
What I want is send the $data
array from externalServer/request.php
to mainServer/default/index.php
, but there is an error Notice: Undefined index: file_name in default\index.php on line 13
.
How to get the $data
array to for instance to print an item ?