Jump to content

I can't add an image Web Service Prestashop


ElPepito

Recommended Posts

When I try to add an image to a product I don't get any errors, but the image doesn't get added.


This is my code:



function addImage($idProduct)
{

$key = 'XXXXXXXXXXXXXXXXXXX';
$url = "http://192.168.1.81/api/images/products/".$idProduct;
$image_path = 'image2.jpg';

$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.';type=image/jpg'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);

echo '<h2>Image Added</h2>';

}

I also made a change on PSWebServiceLibrary.php, because Prestashop Web Service API keeps asking for authentication. This is the link where I got the code Prestashop Web Service API keeps asking for authentication .


This is the code I added:



$url .= '&ws_key=' . $this->key;

The problem is that the code to add an image was working before I made that change on PSWebServiceLibrary.php, and I don't know how to solve it. I am using prestashop 1.6.1.5


Any help will be appreciated.


Greetings!


Link to comment
Share on other sites

  • 5 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...