在我的項目的圖像: -如何發佈到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