あなたはこれを行うことができる目的のCで、PHPサーバーに画像をアップロードしたい:
//To convert your image file to raw.
NSData *imageData = UIImagePNGRepresentation(self.imageView.image);
NSString *urlString = @"http://sample.com/upload.php";
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
//Boundary and Header.
NSString *boundary = @"---------------------------14737809831466499882746641449";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
//Your uploading file.
NSMutableData *bodyData = [NSMutableData data];
[bodyData appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
/*
* Declares the PHP received $_FILES variables.
* - $_FILES['_varName']['name'] = _sample.png
*/
[bodyData appendData:[@"Content-Disposition: form-data; name=\"_varName\"; filename=\"_sample.png\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[bodyData appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[bodyData appendData:[NSData dataWithData:imageData]];
[bodyData appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:bodyData];
//Received response of server.
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
//Dumps it.
NSLog(@"%@", returnString);
お役に立てますように。