I want to upload some media and images to my WordPress site via XML-RPC I used this code for this pupose:
$filename = 'sample.jpg';
$mime = 'images/jpeg';
$data = file_get_contents($filename);
var_dump($wpClient->uploadFile($filename, $mime, $data, false));
The file uploads to the media and I get this output for that:
array(13) {
["attachment_id"]=>
string(4) "7430"
["date_created_gmt"]=>
object(stdClass)#3 (3) {
["scalar"]=>
string(17) "20160727T19:57:29"
["xmlrpc_type"]=>
string(8) "datetime"
["timestamp"]=>
int(1469649449)
}
["parent"]=>
int(0)
["link"]=>
string(56) "http://url.com/wp-content/uploads/2016/07/sample.jpg"
["title"]=>
string(10) "sample.jpg"
["caption"]=>
string(0) ""
["description"]=>
string(0) ""
["metadata"]=>
string(0) ""
["type"]=>
string(11) "images/jpeg"
["thumbnail"]=>
string(56) "http://url.com/wp-content/uploads/2016/07/sample.jpg"
["id"]=>
string(4) "7430"
["file"]=>
string(10) "sample.jpg"
["url"]=>
string(56) "http://url.com/wp-content/uploads/2016/07/sample.jpg"
}
But uploaded file doesn't have any title or description, How can I submit such things for that?
I found the way myself, After uploading the file, We should edit the post and modify those metas