Child pages
  • Chapter 9 - Image management

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleUpdate existing image
<form action="http://eWURcnNJ6mbLUHB10EEIzTZsTShs33IX@myprestahop.com/api/images/customizationsproducts/6/1/82" method="POST" enctype="multipart/form-data">
<fieldset>
	<legend>Update product image change 1/8<2</legend>
	<input name="ps_method" value="PUT" type="hidden">
	<input name="image" type="file">
	<input value="Execute" type="submit">
</fieldset>
</form>

...

Code Block
$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);