0

How can i upload an image using curl through image create functions (imgpng, imagecreatefromstring,..)

This is how i'm currently doing it normally without create functions

curl_setopt($ch, CURLOPT_POST, true);
$post = array(
  "Filedata"=>"@{$file_location}"
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

how to do the same thing with an image function, lets say imagecreatefromstring(file_get_contents($image_link));
and link it with the curl without having to save the file, directly through the function

Osa
  • 1,922
  • 7
  • 30
  • 51

2 Answers2

0
$data = curl_exec($ch);
imageceratefromstring($data);
Erwin
  • 4,757
  • 3
  • 31
  • 41
nsumer
  • 1
0

Here is how. Note that in code you can avoid any encodging and just use it like:

$postFields['my_image'] = someFunctionForCreatingImage();
Community
  • 1
  • 1
kirugan
  • 2,514
  • 2
  • 22
  • 41