在我的项目的图像: -如何发布到Web服务
1)点击从相机拍摄照片(不要保存)。
2)显示裁剪图像,2个按钮,并发布后cancel.where按钮后的图像和取消按钮放弃image.it看起来是这样的。
我不知道如何发布相机捕获图像。我通过互联网搜索发现了很多代码,但没有找到任何代码可以帮助我。
我想这些链接给代码..
我希望有人会help..how张贴?谢谢。
-(IBAction)sendRequest:(id)sender {
#define DataDownloaderRunMode @"myapp.run_mode"
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60];
[request setHTTPMethod:@"POST"];
NSString *boundary = @"----WebKitFormBoundarycC4YiaUFwM44F6rT";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name="attachment[file]";
filename="picture.png"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: image/png\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
delegate:self
startImmediately:NO];
[connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:DataDownloaderRunMode];
[connection start];
}
和连接此张贴..按钮
是第一个链接不正是你想要的东西,如果你有,你应该具体问题发布您的代码和任何错误 – wattson12
@ wattson12 TNX ... – Shivaay
@ wattson12当我使用第一个链接的代码,它显示的错误在这条线...... [机构appendData:[NSST ring stringWithString:@“Content-Disposition:form-data; NAME = “附件[文件]”;filename =“picture.png”\ r \ n“] dataUsingEncoding:NSUTF8StringEncoding]]; – Shivaay