ios 从系统相册选择多张图片

来源:互联网 发布:起飞了是什么网络意思 编辑:程序博客网 时间:2024/05/01 01:16


http://blog.csdn.net/linzhu0831/article/details/7469223



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 = [[AFHTTPRequestSerializerserializer] multipartFormRequestWithMethod:@"POST"URLString:url parameters:url参数 constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {

       for (int i =0; i<arrayImage.count; i++) {

           UIImage *uploadImage = arrayImage[i];

            [formDataappendPartWithFileData:UIImagePNGRepresentation(uploadImage)name:[NSStringstringWithFormat:@"参数%d",i+1]fileName:@"test.jpg"mimeType:@"image/jpg"];

        }

    }error:nil];


AFHTTPRequestOperation *opration = [[AFHTTPRequestOperationalloc]initWithRequest:request];   

opration.responseSerializer.acceptableContentTypes = [NSSetsetWithObject:@"text/html"];

[opration setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation,id responseObject) {


}failure:^(AFHTTPRequestOperation *operation,NSError *error) {


}


0 0
原创粉丝点击