« PreviousNext »

Upload image with Windows Live Writer

1 February 2007

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.

Posted in I.T. | Tags No Tags | 10,315 Views | Trackback | del.icio.us | Top Of Page
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5 out of 5)  
Loading ... Loading ...

    9 Responses to “Upload image with Windows Live Writer”

  1. Leroy Brown Says:

    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?

  2. Rocky Says:

    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.

  3. Derek Snyder Says:

    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!

  4. Rocky Says:

    Derek, may I know the version of your wordpress?

  5. Richard Says:

    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 (”).

  6. Rocky Says:

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

  7. kosiew Says:

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

  8. Dale Says:

    still no go. same error

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

  9. Emad Ibrahim Says:

    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

Leave a Reply