- UIImage *im = [UIImage imageWithContentsOfFile:path];
- NSData *data = UIImagePNGRepresentation(im);
- NSMutableData *imageData = [NSMutableData dataWithData:data];
- NSURL *url = [NSURL URLWithString:@"服务器地址"];
- ASIFormDataRequest *aRequest = [[ASIFormDataRequest alloc] initWithURL:url];
- [aRequest setDelegate:self];
-
- [aRequest setRequestMethod:@"POST"];
- [aRequest setPostBody:imageData];
- [aRequest addRequestHeader:@"Content-Type" value:@"binary/octet-stream"];
-
- [aRequest startAsynchronous];
- [aRequest setDidFinishSelector:@selector(headPortraitSuccess)];
- [aRequest setDidFailSelector:@selector(headPortraitFail)];
- [aRequest release];
ASIFormDataRequest实现上传图片,布布扣,bubuko.com
ASIFormDataRequest实现上传图片
原文:http://www.cnblogs.com/wlcc/p/3906968.html