通过HTTP POST发送图像数据

时间:2012-11-27 06:36:57

标签: iphone objective-c cocoa-touch ios-simulator

如何通过HTTP POST发送图像数据?

我有以下代码:

NSURL *aUrl = [NSURL URLWithString:@"http://demo25.projectproofonline.com/soul_mate_modified/save.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aUrl
cachePolicy:NSURLRequestUseProtocolCachePolicy  timeoutInterval:60.0];
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPMethod:@"POST"];
[NSURLConnection connectionWithRequest:request delegate:self];

1 个答案:

答案 0 :(得分:0)

所以一种方法是通过执行多部分图像上传,但这不是json格式,但这确实是正常做法,可能是您唯一的选择。 Multipart/Formdata image upload, get the file