iPhone APP-如何上传图像到.NET C#WCF? [英] iPhone app- How to upload image to .net C# WCF?

查看:149
本文介绍了iPhone APP-如何上传图像到.NET C#WCF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的iPhone应用程序连接到WCF服务。现在我需要添加一个上传照片功能,我的iPhone应用程序。这就是说,我需要让我的WCF服务接受图像并保存到我的服务器。任何想法如何实现这一目标?

I have a WCF service that my iPhone app is connected to. Now I need to add an upload photo feature to my iPhone app. That said, I needed to have my WCF service to accept Images and save it to my server. Any idea how to achieve this?

我没有使用Google的一些可能的解决方案,但他们都没有为我工作。

I did googling for some possible solutions but neither of them works for me.

您回应大大AP​​ preciated。

Your responses is greatly appreciated.

推荐答案

样品code段,没有错误张贴图像检查只是基本的code

sample code snippet, no error checking just basic code for posting image

// get image from somewhere...
NSData *imageData = UIImageJPEGRepresentation(image, 90);

NSString *urlString = @"http://yourserver.com/upload_image";

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSMutableData *postBody = [NSMutableData data];

//add image data to POST
[postBody appendData:[NSData dataWithData:imageData]];

[request setHTTPBody: postBody];

// connect to the web
NSData *respData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *respStr = [[NSString alloc] initWithData:respData encoding:NSUTF8StringEncoding];

这篇关于iPhone APP-如何上传图像到.NET C#WCF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆