我已将图像文件发布到具有 php 文件的服务器。
我使用了以下代码:
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
byte[] sbytedata = ReadToEnd(e.ChosenPhoto);
string s = sbytedata.ToString();
WebClient wc = new WebClient();
Uri u = new Uri("http://example.com/file.php");
wc.OpenWriteCompleted+=new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);
wc.OpenWriteAsync(u, "POST", sbytedata);
}
}
public static void wc_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e)
{
if (e.Error == null)
{
object[] objArr = e.UserState as object[];
byte[] fileContent = e.UserState as byte[];
Stream outputStream = e.Result;
outputStream.Write(fileContent, 0, fileContent.Length);
outputStream.Flush();
outputStream.Close();
string s = e.Result.ToString();
}
}
但是如何从返回图像文件的服务器读取响应以及如何显示该图像?