ios AfNetWoring 上传多张图片
来源:互联网 发布:多功能网络表 编辑:程序博客网 时间:2024/05/24 15:39
AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManagermanager];
//设置返回的数据解析格式
manager.responseSerializer.acceptableContentTypes= [NSSet setWithObject:@"text/html"];
//以下为上传的一些参数,根据服务器网址要求,可以有可以没有
NSString*uid = [[NSUserDefaults standardUserDefaults] objectForKey:@"myUid"];
NSString *valueWWW= [NSStringstringWithFormat:@"{"uid":"%@"}",uid];
NSMutableDictionary*ssdict = [[NSMutableDictionary alloc] init];
[ssdict setValue:valueWWWforKey:@"home"];
//post方法进行图片上传
AFHTTPRequestOperation*operation = [manager POST:@"http://public.aiweiker.com/index.php?g=App&m=HomePage&a=updateBg"parameters:ssdictconstructingBodyWithBlock:^(id<</span>AFMultipartFormData> formData) {
//将图片装换为二进制格式--UIImageJPEGRepresentation第一个参数为要上传的图片,第二个参数是图片压缩的倍数
//如果要上传多张图片把下面两句代码放到for循环里即可
for (int i =0; i<</span>0; i++) {
NSData *imageData =UIImageJPEGRepresentation(image, 0.1);
[formData appendPartWithFileData:imageData name:[NSString stringWithFormat:@"anyImage_%d",i]fileName:[NSString stringWithFormat:@"anyImage_%d.jpg",i] mimeType:@"image/jpeg"];
}
} success:^(AFHTTPRequestOperation *operation,id responseObject) {
//成功的返回--进行你的操作
NSDictionary *dict = responseObject;
} failure:^(AFHTTPRequestOperation *operation,NSError *error) {
//失败的返回
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:nilmessage:@"请检查网络" delegate:selfcancelButtonTitle:@"确定"otherButtonTitles:nil];
[alert show];
[alert release];
}];
//获得上传进度
[operation setUploadProgressBlock:^(NSUInteger bytesWritten,long long totalBytesWritten,long long totalBytesExpectedToWrite) {
NSLog(@"百分比:%f",totalBytesWritten*1.0/totalBytesExpectedToWrite);
}];
- ios AfNetWoring 上传多张图片
- iOS AFNetWoring单张上传图片
- IOS 上传多张图片
- iOS上传多张图片
- iOS多张图片上传
- IOS 上传多张图片
- IOS 利用ASIHttpRequest 上传多张图片
- iOS AFNetworking 上传多张图片
- iOS 使用AFNet上传图片(多张)
- IOS 利用AFN上传图片,支持多张、单张上传
- 多张图片上传
- 上传多张图片
- 上传多张图片
- 多张图片上传
- iOS 用ASIHTTPRequest框架 上传多张图片
- iOS用ASIHTTPRequest框架实现多张图片上传
- iOS开发 使用AFNetworking实现多张图片上传
- iOS学习笔记:afnetworking上传多张图片
- c++读取文件操作之peek、>>和get
- Android应用签名
- udev的实现原理
- android常用权限
- 要获得表中每一个时间time对应的f_value的最大值,该sql应该如何实现
- ios AfNetWoring 上传多张图片
- NANDFlash结构图解
- [Shell Command] MySQL集群全局一览表【源码】
- Java注解@interface (入门)
- online_judge_1046
- 百度地图开发
- Remove Duplicates from Sorted Array II
- Android.mk简介
- android canva画人