Jump to content

Add new image category with curl


Recommended Posts

Hi all,

 

Im trying to upload image to a existing category using curl, i CAN update an image but i CANT add a new image: 

 

My code: (category 50 exists)

 

$ch = curl_init();
$cfile = curl_file_create($urlImage,'image/jpeg','image');
$data = array('image' => $cfile);
 
 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $apiKey.':');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch,CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
 
It returns a 400 error.
 
PS version: 1.6
 
Thanks all
Link to comment
Share on other sites

×
×
  • Create New...