WordPress Can not upload an image through wp.uploadFile using c#

I’m working on a .net program to communicate with wordperss through xml-rpc.net. I found that if I’m trying to upload an image which is kind of large through “wp.uploadFile”, wordpress will return an error saying ” parse error(-32700), well not formed”. I tried Windows Live Write to write a post. However, if I choose to link the source picture, I got an error saying I can’t upload an image, and uploading images through ftp was suggested.

I found this article:
Image Uploading Fails

Read More

I think there may still be some issue in reading large request does not contain break lines, so I build the xml myself, and add a break line (‘rn’) every 76 characters according to RFC 822. But the issue is still there, in another word, I can not upload any kinda large images.
my xml file is as follow:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<methodCall>
  <methodName>wp.uploadFile</methodName>
  <params>
    <param>
      <value>
        <i4>0</i4>
      </value>
    </param>
    <param>
      <value>
        <string>myname</string>
      </value>
    </param>
    <param>
      <value>
        <string>mypwd</string>
      </value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>name</name>
            <value>
              <string>MS-wedge.jpg</string>
            </value>
          </member>
          <member>
            <name>type</name>
            <value>
              <string>image/jpeg</string>
            </value>
          </member>
          <member>
            <name>bits</name>
            <value>
              <base64>
/9j/4AAQSkZJRgABAQEBLAEsAAD7gAOQWRvYmUAZAAAAAAB+EVpkV4aWYAAE1NACoAAAAIABAB
AAADAAAAARIAAAABAQADAAAAAQwAAAABAgADAAAAAwAAAM4BBgADAAAAAQACAAABDwACAAAAEgAA
<!-- ... pending other data -->
</base64>
            </value>
          </member>
          <member>
            <name>overwrite</name>
            <value>
              <boolean>false</boolean>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>

Related posts

Leave a Reply

1 comment

  1. I’ve been working with WordPress XML-RPC for over 3years.
    I attached a Upload request sample that working fine as your reference. I hope this could help you.

    <?xml version="1.0"?>
        <methodCall><methodName>wp.uploadFile</methodName>
            <params>
                <param>
                    <value><string>1</string></value>
                </param>
            <param>
                    <value><string>username</string></value>
            </param>
            <param>
                    <value><string>password</string></value>
            </param>
            <param>
                    <value><struct>
                        <member>
                            <name>name</name>
                            <value><string>Photo Jun 27, 2013, 3:08 PM.jpg</string></value>
                        </member>
                        <member><name>type</name><value><string>image/jpeg</string></value>
                        </member>
                        <member><name>bits</name><value><base64>/9j/4AAQSkZJRgABAQAAAQABAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQA
    <!-- ... pending other data -->
    </base64></value></member>
                        <member><name>overwrite</name><value><string>false</string></value></member></struct></value></param></params></methodCall>