wp.uploadFile XML RPC : image size zero

I am trying to upload image to wordpress by xml-rpc:

$dir = getcwd().'/upload/post/';
$thumbnail_img = $post['thumbnail_img'];
$mime_type = mime_content_type($dir.$thumbnail_img);
$theData = file_get_contents('http://tf_test.local/upload/post/'.$thumbnail_img);

$data = array(
    'name'=>'ddd.txt',
    'type'=>$mime_type,
    'bits'=>new IXR_Base64($theData),
    'overwrite' => false
);
$client = new IXR_Client($media['url'].'xmlrpc.php');
$params = array(0, $media['media_id'], $media['password'], $data);
if (!$client->query('wp.uploadFile', $params)) {
    print ($client->getErrorCode().":".$client->getErrorMessage());
}
return $client->getResponse();

There is no errors, but uploaded image size is zero!

Read More

Text files are uploaded without any problems (ex: log.txt).

Related posts