简体   繁体   中英

PHP curl upload from image create functions

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 , directly through the function

$data = curl_exec($ch);
imageceratefromstring($data);

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

$postFields['my_image'] = someFunctionForCreatingImage();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM