ios 从系统相册选择多张图片
2015-11-24 22:34
513 查看
/article/7912228.html
http://www.xuanyusong.com/archives/1493
iOS 富文本视图控件SECoreTextView
http://www.oschina.net/p/secoretextview
https://github.com/kishikawakatsumi
版权声明:本文为博主原创文章,未经博主允许不得转载。
1.单张图片上传
name: 处为url提供的参数名
NSDictionary *dic =@{参数};
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManageralloc]
init];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes =[NSSetsetWithObject:@"text/html"];
[managerPOST:url parameters:dicconstructingBodyWithBlock:^(id<AFMultipartFormData>
formData) {
[formData appendPartWithFileData:UIImagePNGRepresentation(image)name:@"Filedata"fileName:@"test.jpg"mimeType:@"image/jpg"];
}success:^(AFHTTPRequestOperation *operation,id
responseObject) {
}failure:^(AFHTTPRequestOperation *operation,NSError
*error) {
}];
2.多张图片上传
NSMutableURLRequest *request = [[AFHTTPRequestSerializer
serializer] multipartFormRequestWithMethod:@"POST"
URLString:url parameters:url参数 constructingBodyWithBlock:^(id<AFMultipartFormData>
formData) {
for (int i =
0; i<arrayImage.count; i++) {
UIImage *uploadImage =
arrayImage[i];
[formData
appendPartWithFileData:UIImagePNGRepresentation(uploadImage)
name:[NSString
stringWithFormat:@"参数%d",i+1]
fileName:@"test.jpg"
mimeType:@"image/jpg"];
}
}
error:nil];
AFHTTPRequestOperation *opration = [[AFHTTPRequestOperation
alloc]initWithRequest:request];
opration.responseSerializer.acceptableContentTypes = [NSSet
setWithObject:@"text/html"];
[opration
setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation,
id responseObject) {
}
failure:^(AFHTTPRequestOperation *operation,
NSError *error) {
}
/article/7912228.html
http://www.xuanyusong.com/archives/1493
iOS 富文本视图控件SECoreTextView
http://www.oschina.net/p/secoretextview
https://github.com/kishikawakatsumi
版权声明:本文为博主原创文章,未经博主允许不得转载。
1.单张图片上传
name: 处为url提供的参数名
NSDictionary *dic =@{参数};
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManageralloc]
init];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes =[NSSetsetWithObject:@"text/html"];
[managerPOST:url parameters:dicconstructingBodyWithBlock:^(id<AFMultipartFormData>
formData) {
[formData appendPartWithFileData:UIImagePNGRepresentation(image)name:@"Filedata"fileName:@"test.jpg"mimeType:@"image/jpg"];
}success:^(AFHTTPRequestOperation *operation,id
responseObject) {
}failure:^(AFHTTPRequestOperation *operation,NSError
*error) {
}];
2.多张图片上传
NSMutableURLRequest *request = [[AFHTTPRequestSerializer
serializer] multipartFormRequestWithMethod:@"POST"
URLString:url parameters:url参数 constructingBodyWithBlock:^(id<AFMultipartFormData>
formData) {
for (int i =
0; i<arrayImage.count; i++) {
UIImage *uploadImage =
arrayImage[i];
[formData
appendPartWithFileData:UIImagePNGRepresentation(uploadImage)
name:[NSString
stringWithFormat:@"参数%d",i+1]
fileName:@"test.jpg"
mimeType:@"image/jpg"];
}
}
error:nil];
AFHTTPRequestOperation *opration = [[AFHTTPRequestOperation
alloc]initWithRequest:request];
opration.responseSerializer.acceptableContentTypes = [NSSet
setWithObject:@"text/html"];
[opration
setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation,
id responseObject) {
}
failure:^(AFHTTPRequestOperation *operation,
NSError *error) {
}
相关文章推荐
- iOS跳转到指定页面,而不是简单的返回上一个页面
- 图形变换之使用坐标变换
- iOS视图生命周期
- iOS单例的两种实现
- ios中nsdate与实际时间相隔八小时解决方案
- 【IOS】AutoLayout框架Masonry
- iOS_使用NSURLSessionDataDelegate的代理方法下载数据
- iOS_NSURLSession
- iOS设备下添加button的按下效果
- ios 枚举 位移操作
- IOS响应者链,事件传递和阻断
- iOS学习之场景跳转的三种方式
- iOS中几种数据持久化方案:我要永远地记住你!
- IOSJSBRIGE商品内容模板
- 无法打开包括文件:“iostream.h”
- iOS9 应用之间跳转可以点击左上角进行跳转
- ios jsbrige
- iOS通过CLLocationManager调用地图导航功能
- iOS开发多线程-线程的状态
- BIOS加电自检