Need help? Check out our Support site, then


Upload Image using xmlrpc.php (SCRIPT!)

  1. Does anyone have a script (preferably php) that I can use to upload an image to my wordpress.com blog by calling xmlrpc.php?

    Example: take the image, http://www.desdelahabana.net/wp-content/uploads/2010/03/Sobreviviendo-en-el-socialismo-cubano-168x300.jpg and upload a copy of it to desdeaquifromhere.wordpress.com blog so that I can reference it in a post.

    Note: This is used in our wordpress.com blogs which are translations of Cuban bloggers because we want to preserve the images since they often go away in the original blog. Right now, we just reference the original image in our translated posts but that has resulted in losing images when the original Cuban post is moved or deleted.

    The blog I need help with is desdeaquifromhere.wordpress.com.

  2. The metaWeblog.newMediaObject will work for uploading files via XML-RPC.

  3. Thanks...I am looking at the docs for metaWeblog.newMediaObject but am a novice at using XML-RPC. So I understand the function call itself but not the overall way one would use it in a php script.

    Do you perhaps have some example code?

  4. Using the IXR library that comes with WP it's pretty easy:

    $data = array(
        'name'  => 'andy.avi',
        'type'  => 'video/x-msvideo',
        'bits'  => new IXR_Base64( dirname( __FILE__ ) . '/MVI_0649.AVI' )
    );
    
    $rpc = new IXR_Client( $rpc_url );
    $status = $rpc->query(
        'metaWeblog.newMediaObject',
        $blog_id,
        $username,
        $password,
        $data
    );

    You may want to try the WordPress.org support forums as well, there's nothing specific to WordPress.com in this.

  5. Many thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic