$url = 'http://myprestashop.com/api/images/products/1';
/**
* Uncomment the following line in order to update an existing image
*/
//$url = 'http://myprestashop.com/api/images/products/1/2?ps_method=PUT';
$image_path = 'C:\\my_image.png';
$key = 'My web service key';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $key.':');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => '@'.$image_path));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
|