您的位置:首页 > 移动开发 > IOS开发

AFNetworking如何向服务器提交图片 ios中获取图片并上传图片

2015-05-27 11:52 441 查看
NSURL *url = [NSURL URLWithString:[DATAWEBURL stringByAppendingString:ADDEMAILURL]];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

NSData *data = UIImagePNGRepresentation(im);//获取图片数据

/*

ios中获取图片的方法有两种,一种是UIImageJPEGRepresentation ,一种是UIImagePNGRepresentation

前者获取到图片的数据量要比后者的小很多。。

*/

NSMutableData *imageData = [NSMutableData dataWithData:data];

[request setPostBody:imageData];

[request setDelegate:self];

[request setDidFinishSelector:@selector(checkUpdateFinished:)];

[request setDidFailSelector:@selector(checkUpdateFailed:)];

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

[appDelegate.networkQueue addOperation:request];

[appDelegate.networkQueue go];

http://www.cocoachina.com/bbs/read.php?tid-251627.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: