[Cpp]
? UIImage * im = [UIImage imageWithContentsOfFile: path]; // obtain the image through path
NSData * data = UIImagePNGRepresentation (im); // obtain image data
/*
There are two methods for obtaining images in ios: UIImageJPEGRepresentation and UIImagePNGRepresentation.
The data size obtained by the former is much smaller than that obtained by the latter ..
*/
NSMutableData * imageData = [NSMutableData dataWithData: data]; // The setPostBody method of ASIFormDataRequest requires the NSMutableData type
NSURL * url = [NSURL URLWithString: @ "server address"];
ASIFormDataRequest * aRequest = [[ASIFormDataRequest alloc] initWithURL: url];
[ARequest setDelegate: self]; // proxy
[ARequest setRequestMethod: @ "POST"];
[ARequest setPostBody: imageData];
[ARequest addRequestHeader: @ "Content-Type" value: @ "binary/octet-stream"]; // The value here must be consistent with that on the server.
[ARequest startAsynchronous]; // start. Asynchronous
[ARequest setDidFinishSelector: @ selector (headPortraitSuccess)]; // The headPortraitSuccess method is automatically triggered when the request succeeds.
[ARequest setDidFailSelector: @ selector (headPortraitFail)]; // if it fails, the headPortraitFail method is automatically triggered.
[ARequest release];