WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#26318 new defect (bug)

XMLRPC wp.uploadFile fails to place media in sub blogs

Reported by: daki-san Owned by:
Milestone: Awaiting Review 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)

#1 @markoheijnen
4 years ago

We don't deal with blog IDs. You should always upload to the url of the site

#2 @daki-san
4 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

`

#3 @markoheijnen
4 years ago

Well, they aren't outdated. The first parameter is for that except it's missing that it's still and most likely never will be implemented.

#5 @chriscct7
2 years ago

  • Keywords needs-codex added

Looks like this just need a Codex update

Note: See TracTickets for help on using tickets.