Upload image with Windows Live Writer
1 February 2007Windows 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 Responses to “Upload image with Windows Live Writer”
February 9th, 2007 at 00:02
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?
February 9th, 2007 at 12:20
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.
February 19th, 2007 at 13:02
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!
March 6th, 2007 at 12:44
Derek, may I know the version of your wordpress?
April 10th, 2007 at 06:38
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 (”).
April 11th, 2007 at 14:54
Thanks to Richard. I’ve updated the source code.
April 11th, 2007 at 18:49
This worked for me.
I posted to www.onnraves.com (wordpress 2.1.2) with Windows Live Writer 1.0.1(6).
May 13th, 2007 at 04:02
still no go. same error
invalid server response
The response to the metaWeblog.newMediaObject method received from the weblog server was invalid.
July 19th, 2007 at 23:35
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