前面我们说过上传图片的第一种方法就是把图片转成图片流进行上传;今天再给大家介绍别一种做法。就是使用Afnetworking中封装好的方法使用URL的方式去上传。具体后台怎么去接收我就不知道清楚了。
老样子话不多说直接上代码。
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];//实例化afn
AFJSONResponseSerializer *response = [AFJSONResponseSerializer serializer];
//json传送方式
response.removesKeysWithNullValues = YES;
manager.responseSerializer = response;
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
[manager POST:URL parameters:
NSDictionary
constructingBodyWithBlock:
(void (^)(id))
success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) {
success(responseObject);
} failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {
failure(error);
}];
其中(void (^)(id))为上传对像
图片可以是单张也可以是多张
单张 :[formData appendPartWithFileData:UIImagePNGRepresentation(image) name:@"images" fileName:@"name.png" mimeType:@"image/png"];
多张:把此方法做循环把图片排成队列即可;
注意: namec参数一定与后台一样否则后台接收不到
韩剧再婚皇后阿里云盘全集高清1080P资源链接-韩剧再婚皇后免费阿里云盘资源下载4K高清无删减版链接
poipiku网站如何打开-poipiku官网网页版访问入口
明日方舟:终末地-云游戏畅玩入口-明日方舟:终末地-网页版在线直连地址
poki在线小游戏网页版-poki免费游戏大全入口
poki游戏入口-点开即玩-poki游戏-在线免费畅玩
原神akt大佬资源viciNeko入口链接-原神akt大佬资源网页vicineko入口链接分享