Child pages
  • Chapitre 9 - Gestion des images

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

URL : /images/categories/2

Wiki MarkupParamètres : images=\[Contenu binaire de l'image à envoyer\]

Exemple d'ajout d'une image produit au produit ayant pour identifiant 1 :

Méthode HTTP : POST

URL : /images/products/1

Wiki MarkupParamètres : images=\[Contenu binaire de l'image à envoyer\]

Code HTML permettant au navigateur d'envoyer l'image associée :

Code Block


<form enctype="multipart/form-data" method="POST" action="http://[email protected]/api/images/products/1">

<fieldset>
<legend>Add image for products No 1</legend>
<input type="file" name="image">
<input type="submit" value="Execute">
</fieldset>
</form>

...

Code Block

$url = 'http://maboutique.com/api/images/products/1';

$image_path = '\[C:\\mon_image.png\]';

$key = "\['Ma clé webservice\]"';


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);

//curl_setopt($ch, CURLOPT_PUT, true); Pour modifier une image
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);