2017-06-29 3 views
0

Ich versuche Produktbilder mit Prestashop dev's example hochzuladen.Prestashop 1.7 importiert kein Produktbild über cUrl

Hier ist mein Code:

$image_path = 'http://www.naminukas.lt/out/pictures/master/straipsniai/thumb/skalbimo_masinos_pelesis.jpg'; 
$url = 'http://46.101.240.63/api/images/products/198'; 
$key = 'myapicode'; 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, true); 
//curl_setopt($ch, CURLOPT_PUT, true); // Un-commet to edit an 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); 

Dann versuche ich mit HTML-Code zu laden, ist es funktioniert

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

aber mit curl es nicht und immer Fehler 66, kann nicht Lade dieses Bild hoch.

Haben Sie irgendwelche Ideen?

P.S: Ich benutze PHP 7.0 Version.

Antwort

0

Sie haben ein SSL-Fehler: https://curl.haxx.se/libcurl/c/libcurl-errors.html

versuchen, diese Zeilen hinzufügen Zertifikate und SSL-bezogenen Warnungen zu ignorieren. curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, 0);

Verwandte Themen