无法使用Windows Phone 8应用中的Web服务将图像上传到服务器 [英] Not able to upload image to the server using web service in windows phone 8 app
本文介绍了无法使用Windows Phone 8应用中的Web服务将图像上传到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Windows开发的新手。我尝试了很多将图像上传到服务器,但我无法这样做。
如果有人可以帮助我,请参阅下面的代码
I a new to windows development. I tried a lot to upload an image to the server, but I am unable to do so.
If anyone can help me out, please see my code below
void uploadphoto()
{
WebClient webClient1 = new WebClient();
webClient1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient1_DownloadStringCompleted);
webClient1.DownloadStringAsync(new Uri("Web Service"));
}
void webClient1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
var rootobject1 = JsonConvert.DeserializeObject<RootObject1>(e.Result);
int error = rootobject1.response.errorFlag;
string message = rootobject1.response.msg;
if (error == 0)
{
MessageBox.Show(message);
}
else
{
MessageBox.Show(message);
}
}
public class Response1
{
public int errorFlag { get; set; }
public string msg { get; set; }
public List<string> uploadedImageNames { get; set; }
}
public class RootObject1
{
public Response1 response { get; set; }
}
我使用下面的代码来选择图像:
And I am using the code below for selecting the image:
private void ImageUpload(object sender, RoutedEventArgs e)
{
//MessageBoxResult mb = MessageBox.Show("Select the mode of uploading the picture", "", MessageBoxButton.OKCancel);
Popup popup = new Popup();
photoSelection photo = new photoSelection();
popup.Child = photo;
popup.IsOpen = true;
photo.camera.Click += (s, args) =>
{
photoCameraCapture.Show();
popup.IsOpen = false;
};
photo.library.Click += (s, args) =>
{
photoChooserTask.Show();
popup.IsOpen = false;
};
}
我正在使用这些代码开发适用于Windows Phone 8的应用程序。我正在使用Json.Net.Please帮助我出去提前完成。
I am using those code for developing app for Windows Phone 8. I am using Json.Net.Please help me out. Thanx in advance.
推荐答案
http://blog.anthonybaker.me/2013/06/how-to-connect-to-local-web-services.html
谢谢,
Bilaal
http://blog.anthonybaker.me/2013/06/how-to-connect-to-local-web-services.html
Thanks,
Bilaal
这篇关于无法使用Windows Phone 8应用中的Web服务将图像上传到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文