WordPress上传的图像是空白的

本文关键字:空白 图像 WordPress | 更新日期: 2023-09-27 18:31:20

我通过使用c#与xml-rpc通信将图像上传到wordpress。这是我关于图像转换的代码。上传部分有效。但是,当我在wordpress上检查实际图像时,它是一张空白图片。我做错了什么?谢谢。

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);

WordPress上传的图像是空白的

对于任何有同样问题的人,我找到了解决方案。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 转到此链接。功劳归于MSDN论坛的Hetro wong。刚刚使用了Joeblogs UploadImage,一切都很顺利。不需要上面显示的代码。谢谢你,先生。