Uploads aren’t created correctly via XML-RPC (metaWeblog, newMediaObject)

  • Unknown's avatar

    I’m uploading images via XML-RPC using metaWeblog.newMediaObject
    My code seems to work fine, because after the upload I become as answer something like:

    array(3) { [“file”]=> string(8) “Aara.jpg” [“url”]=> string(66) “http://myblog.com/wp-content/uploads/2010/09/Aara.jpg” [“type”]=> string(10) “image/jpeg” }

    But if I check the uploaded image, it is just a few bytes big and has a size of 0 x 0 pixel. Does anyone knows whats wrong?
    This is my code (PHP):


    $XmlRpc_result = null;
    $XmlRpc_client = new IXR_Client ($data['Blog']['url'].'/xmlrpc.php');

    $image = array
    (
    'name' => 'Aara.jpg',
    'type' => 'image/jpeg',
    'bits' => new IXR_Base64 (dirname ( __FILE__).'/image.jpg')
    );

    try
    {
    $XmlRpc_result = $XmlRpc_client->query
    (
    'metaWeblog.newMediaObject',
    1,
    $data['Blog']['wp_user'],
    $data['Blog']['wp_pw'],
    $image
    );

    var_dump ($XmlRpc_result);
    }
    catch (Exception $e)
    {
    var_dump ( $e->getMessage ());
    }

    I also tried using the Zend_XmlRpc_Client Class form the Zend Framework, with the same result.
    The image I’m uploading is around 80 Kb big and with a size of 600×400 px.

    Thanks a lot in advance for any answer.

  • Unknown's avatar

    You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.

    If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.

    This is an automated message.

  • The topic ‘Uploads aren’t created correctly via XML-RPC (metaWeblog, newMediaObject)’ is closed to new replies.