ruben.bautista Posted October 30, 2018 Share Posted October 30, 2018 Hola chicos, al crear un producto, no me genera su imagen correspondiente, y no se porque ya que ahce tiempo me permitia generarlos y ahora no. Os paso el ejemplo que utilizo, las lineas comentadas con porque lo he intentado de esa manera tambien y la api no me devuelve nada ni crea la imagen. public function addImage($producto_id,$ruta_imagen){ $image_path = __DIR__."/../../assets/img/productos/".$ruta_imagen; $url_shop = PS_SHOP_PATH."api/images/products/$producto_id"; echo "</br>"; echo "EXISTE: ".file_exists($image_path)."</br>"; echo "PRODUCTO_ID: ".$producto_id."</br>"; echo "RUTA IMAGEN: ".$image_path."</br>"; echo "RUTA LLAMADA: ".$url_shop."</br>"; echo "USER: ".PS_WS_AUTH_KEY."</br>"; echo "KEY: ".PS_WS_AUTH_KEY."</br>"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url_shop); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':'); //curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => new CurlFile($image_path))); curl_setopt($ch, CURLOPT_POSTFIELDS, array('image'=>"@".$image_path)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //$result = curl_exec($ch); echo "<pre>CH: ";print_r($ch);echo "</pre>"; if(curl_exec($ch) == false){ echo "<br><br>Error : ".curl_error($ch)."<br>"; } else{ echo '<br><br> Image added'; } curl_close($ch); } y los echos que veis ahi arriba me devuelven lo siguiente. PRODUCTO_ID: 1414 RUTA IMAGEN: /var/www/xxxxx/xxxxx/xxxx/xxxxx/../../xxxx/xxxx/xxxx/xxxx/xx/xx/74376500.png EXISTE: 1 RUTA LLAMADA: http://xxxxxx.webprestashop.com/api/images/products/1414 USER: xxxxxxxxxxxxxxxxxx KEY: xxxxxxxxxxxxxxxxxx Muchas gracias a todos! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now