TODO:
Have you ever wanted to post an image to a .Net Web Service using cURL and PHP?
SOLUTION:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_URL, 'http://my.service.com/MyService.asmx/MyMethod' );
$post_array = array(
"FileName"=>'test.jpg',
"ImageData"=>'@C:/test.jpg',
"Param1"=> 'data1',
"Param2"=> 'data2'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
$response = curl_exec($ch);
print_r($response);
?>
NOTES:
.Net Web Service Method should be parameterless, and use the HttpContext and HttpFileCollection objects.