Community mailing list archives

community@mail.odoo.com

How to send image an Image Xml-RPC / php

by
loic
- 12/02/2014 16:33:15
I try


I try to export my images to Odoo, but I have a problem with my script and I don't know where it is. Are you suggestion?

Thanks

  $products_image =  DIR_FS_CATALOG_IMAGES . $product['products_image']; //   ex:  /home/www/catalog......./toto.png
  $type = pathinfo($products_image, PATHINFO_EXTENSION);
  $data = file_get_contents($products_image);
  $data = str_replace(array('+','/','='),array('-','_',''),$data);
  $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
   $products_image_odoo = $base64;

information xml-rpc for image

    "image" => new xmlrpcval($products_image_odoo,"base64"),
    "image_medium" => new xmlrpcval($products_image_odoo,"base64"),
    "image_small" => new xmlrpcval($products_image_odoo,"base64"),
------------------------
Cordialement,
loïc