I'm trying to send xml to a rest server.
$url = url;
$file = 'finn/test.xml';
$post = array('name' => 'fil','file_contents'=>'@'.$file);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
When I run this code I get a blank response.
I know there's nothing wrong with the server or the xml because when I use this to just upload the file to the server everything works fine.
<html>
<body>
<form name="bilupload" action="url" method="post" enctype="multipart/form-data">
partner: <input TYPE="FILE" NAME="fil" size="10">
<br>
<input type="submit" value="Send">
</form>
</body>
</html>
curl_getinfo prints this:
[url] => url
[content_type] => text/html;charset=ISO-8859-1
[http_code] => 200
[header_size] => 497
[request_size] => 144
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.062231
[namelookup_time] => 2.7E-5
[connect_time] => 0.016873
[pretransfer_time] => 0.016928
[size_upload] => 3668
[size_download] => 35
[speed_download] => 562
[speed_upload] => 58941
[download_content_length] => 35
[upload_content_length] => 3668
[starttransfer_time] => 0.034394
[redirect_time] => 0
I've been struggling with this for quite some time and I would be very grateful if anyone could point me in the right direction.