WordPress api post image raw data without being blank in media library

I found a solution ! file_put_contents($filepath, base64_decode($data)); // Make sure the image exist if (!file_exists($filepath)){return;} // Load the image $file = file_get_contents($filepath); // Get the filename $filename = $image_name? $image_name : basename($filepath); // Initiate curl. $ch = curl_init(); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true); curl_setopt( $ch, CURLOPT_URL, $url .’/wp-json/wp/v2/media/’ ); curl_setopt( $ch, CURLOPT_POST, 1 ); curl_setopt( $ch, … Read more