【发布时间】:2013-04-07 11:21:31
【问题描述】:
使用web client 将图像上传到网络服务时遇到问题,
我的代码是--->
Uri uri = new Uri("http://localhost/Test/SaveImage");
string imageData = Convert.ToBase64String(data);
WebClient web = new WebClient();
web.UploadStringAsync(uri, "Post", imageData);
web.UploadStringCompleted += new UploadStringCompletedEventHandler(web_UploadStringCompleted);
在上面的代码中,图片转换成字节数组,然后到Base64String上传。
但是在接收端--->
[HttpPost]
public bool SaveImage(string ImageBytes) <---ImageBytes is Null
{
///// some code
}
ImageBytes 参数变空,谁能找出问题所在?
【问题讨论】:
-
它是一个字符串,不应该是字节数组,还是做一个64位的字符串转换,也许行得通。但是字节数组是我的首选。
-
@marko :: 我已经将它转换成 Base64String,你说什么?在接收端或其他地方???
-
如果你做了
UploadStringAsync(uri, "Post", "ImageData=" + imageData)呢? -
不,我现在还不确定。
标签: c# web-services webclient