uploads – Image in binary in the data to WordPress media library

Question

A specific API, returns an image in binary in the data.

If I need to save it to the server, I can easily do it by following the code.

$response = curl_exec($curl); // This is the API response
file_put_contents('example2.png', $response);

How can I add it to the WordPress media library?

0
Ranuka 1 month 2023-02-06T11:11:35-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse