该上传使用的是第三方框架,至于框架的名字就不用多说了
AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
mgr.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
mgr.requestSerializer= [AFHTTPRequestSerializer serializer];
mgr.responseSerializer= [AFHTTPResponseSerializer serializer];
NSDictionary *dic;//上传内容
[mgr POST:@"" parameters:dic constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
NSData *data ;//上传图片
[formData appendPartWithFileData:data name:@“” fileName:@“” mimeType:@"image/png"];
} success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) {
NSLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
NSLog(@"%@",error);
}];