Opened 11 years ago
Last modified 6 years ago
#26318 new defect (bug)
XMLRPC wp.uploadFile fails to place media in sub blogs
Reported by: | daki-san | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.7.1 |
Component: | XML-RPC | Keywords: | needs-codex |
Focuses: | Cc: |
Description
Using an XMLRPC call to mw_newMediaObject, uploaded files do not land in the media library of the target blog, for example blog_id 2. The uploaded files always land in the wp-content/uploads/yyyy/mm folder. And they also appear in the media library for that blog too, via the UI.
If you trace the blog_ID to class-wp-xmlrpc-server.php you can see the method is receiving the correct value (eg. 2) at that point.
This affects (at least) a subdomain-type of installation. The htaccess is standard from the WP codex.
Occurs when blog_ID is passed to the rpc thus:
require_once 'IXR_Library.php'; $client = new IXR_Client('http://my-site.com/xmlrpc.php'); $params = array('name' => 'imgfile.png', 'type' => 'image/png', 'bits' => new IXR_Base64($bits), 'overwrite' => false); $client->query('wp.uploadFile',2, 'admin', 'password', $params);
The xmlrpc returns a packet containing this data:
array ( 'id' => '30', 'file' => 'test2_889047515_2.png', 'url' => 'http://my-site.com/wp-content/uploads/2013/11/imgfile.png', 'type' => 'image/png', )
Change History (5)
#2
@
11 years ago
Thanks. That was it all right.
Although if blog IDs are not dealt with, then the docs are out of date.
`
http://codex.wordpress.org/XML-RPC_WordPress_API/Media
wp.uploadFile
Upload a media file.
Parameters
int blogid
string username
string password
struct data
`
We don't deal with blog IDs. You should always upload to the url of the site