To anyone who has the same problem, I found the solution. Head over to this link http://social.msdn.microsoft.com/Forums/vstudio/en-US/92320e9f-5b9b-481c-bbae-2d9873b47067/how-to-upload-image-to-wordpress-via-xmlrpc-communication-using-c-or-vbnet. Credit goes to Hetro wong from MSDN forums. Just used Joeblogs UploadImage and everything went well. No need for the codes shown above. Thank you Sir.
Wordpress uploaded image is blank
Question
I'm uploading images to wordpress via communication with xml-rpc using c#. This is my code on the image conversion. The uploading part works. However when I check the actual image on wordpress, it's a blank picture. What am I doing wrong? Thank you.
Byte[] buffer = new byte[4096];
Int32 readChars;
while ((readChars = response.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, readChars);
}
MediaObject newBlogImage = new MediaObject();
newBlogImage.bits = ms.ToArray();
newBlogImage.name = Guid.NewGuid().ToString() + realImageName;
newBlogImage.type = Path.GetExtension(realImageName);
if (newBlogImage.type == "" || newBlogImage.type == ".ashx")
{
newBlogImage.name = newBlogImage.name + ".jpg";
newBlogImage.type = ".jpg";
}
info = wrapper.NewMediaObject(newBlogImage);
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow