Hi everybody,
I have following simple code to upload a file through xml-rpc to my wordpress blog. The file appears within the wordpress media library, but the image can't be displayed as it seems to be corrupt. I assume I did something wrong with the base64 encoding.
<?php
require('./wp-includes/class-IXR.php');
$rpc = new IXR_CLIENT('http://myBlog.com/xmlrpc.php');
$image = array(
'name' => 'myTestImagenew.jpg',
'type' => 'image/jpg',
'bits' => base64_encode(file_get_contents("exifTest.jpg")),
'overwrite' => 0);
$status = $rpc->query(
'wp.uploadFile',
1,
'USERNAME',
'PASSWORD',
$image);
if(!$status){
echo 'Error ('.$rpc->getErrorCode().'): '.$rpc->getErrorMessage();
exit;
}
echo 'new post id: '.$rpc->getResponse();
?>
Does anybody have some hints?