I'm to sent an image to the server of one social network using curl. The following code works well if I put the link to the image in $post_params variable. I try to do the same with base64 encoded image and insert base64 code into $post_params variable, but then the code doesn't work. How can I fix the issue and upload base64 image?
<?php
if (isset($_POST["upload_url"])) {
$upload_url = $_POST["upload_url"];
$post_params['photo'] = '@' . 'image.jpg'; // link
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $upload_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
}
?>