Jump to content

Unable to save this image error 66


Martin

Recommended Posts

using PS 1.7, PHP 7, Windows, XAMPP, XDebug

Hello,

I'm new to Prestashop and I can't figure out this error on adding Image files to my shop via webservice.

In a basic version I use the Standard code for adding images found in several posts.

When calling curl_exec($ch) I get a XML-result back but it contains the error 66 Unable to save this Image.

I didn't find any useful Information on the Internet, so I hope somebody here can help me.

I'm also wondering, that there is no detailed description about Images in Prestashop. (of course I read the chapter 9 Image Management)

Unanswered question to me are the following:

- Does the post to the webservice do all necessary tasks (resize to the various image sizes, storing it in the correct Directory)

 - What is the source Location of my Images: the localhost, the prestashop directories or as in my example a local path?

- where are the images stored (directly in the prestashop install Directory under img/p/<id> or at a user definded Location?

Thanks for any answers!

This is my code:

<?php

require_once('./Constants.php');

add_image(10078);

function add_image($id_product) 
{
    $url = PS_SHOP_PATH.'api/images/products/'.$id_product;

    $image_src = 'c:\tmp\image.jpg';                                                     
    $args['file'] = new CurlFile($image_src, 'image/jpeg', "image");
    
    try
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':');
        curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        
        $result = curl_exec($ch);           // returns XML code '66' message 'Unable to save this image'
        
        $err_msg = curl_error($ch);         // no error message here 
        $err = curl_errno($ch);             // no error code here
        $err_str = curl_strerror($err);
        
        curl_close($ch);
    }
    catch (Exception $e) {
        echo $e->getCode();
        echo $e->getMessage();
    }
}    

?>

 

Link to comment
Share on other sites

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...