旌旗博客

2007-02-01

Upload image with Windows Live Writer

Filed under: I.T. — 标签: — rocky @ 17:37

Windows Live Writer (wlw) is a cool blog tool. But sometimes I got a error message from wlw while my post had an image within. My blog system is WordPress 2.1 running on PHP 5.20. Here is a solution:

Modify from line 138 of wp-includes/class-IXR.php as below:

 

    function parse() {
        // first remove the XML declaration
       $rx = '/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m';
       if (preg_match($rx, $this->message, $m)) {
               $encoding = strtoupper($m[1]);
       } else {
               $encoding = "UTF-8";
       }
//        $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
//        if (trim($this->message) == '') {
//            return false;
//        }
        $this->_parser = xml_parser_create($encoding);

    
Now I succeeded in uploading those magnificent pictures which have special characters in its file name.

9 Comments »

  1. I’m still getting this error on one of my blogs.. and if I use this fix, I simply can’t use Windows Live Writer at all. This happens with any picture that I try to upload, and it just started today. Any other ideas?

    评论 by Leroy Brown — 2007-02-09 @ 00:02

  2. Leroy, could I know the version of your blog system? And also you may paste the first 10 lines from the parse() function in class-IXR.php file.

    评论 by Rocky — 2007-02-09 @ 12:20

  3. I’m having the same issue, where image uploads no longer work. I tried your fix but after doing so I couldn’t upload any posts whatsoever. Any other ideas? Thanks!

    评论 by Derek Snyder — 2007-02-19 @ 13:02

  4. Derek, may I know the version of your wordpress?

    评论 by Rocky — 2007-03-06 @ 12:44

  5. Brilliant! Thanks. I think some people may have trouble when they copy and paste your code though.. hint: you need to replace all the back ticks (`), etc. with an apostrophe (‘) and likewise with the double back ticks with quotation marks (“).

    评论 by Richard — 2007-04-10 @ 06:38

  6. Thanks to Richard. I’ve updated the source code.

    评论 by Rocky — 2007-04-11 @ 14:54

  7. This worked for me.
    I posted to http://www.onnraves.com (wordpress 2.1.2) with Windows Live Writer 1.0.1(6).

    评论 by kosiew — 2007-04-11 @ 18:49

  8. still no go. same error

    invalid server response
    The response to the metaWeblog.newMediaObject method received from the weblog server was invalid.

    评论 by Dale — 2007-05-13 @ 04:02

  9. I had similar problems with WLW and WPMU and blogged about it at http://emad.blogstogo.com/category/windows-live-writer/
    Thanks for your help

    评论 by Emad Ibrahim — 2007-07-19 @ 23:35

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress