1 ASI Post biography pictures
Nsurl *url=[nsurl urlwithstring:[baseurl stringbyappendingstring:@ "/user/post_face.php"];
Asiformdatarequest *request=[asiformdatarequest Requestwithurl:url];
request.delegate=self;
request.timeoutseconds=120;
[Email protected] "POST";
Nsuserdefaults *defaluts=[nsuserdefaults Standarduserdefaults];
NSData *data=uiimagejpegrepresentation (editedimage, 1);
[Request Setdata:data withfilename:@ "Aa.png" andcontenttype:@ "Image/png" forkey:@ "user_img"];
[Request Setpostvalue:[defaluts objectforkey:@ "token"] forkey:@ "token"];
[Request startasynchronous];
2 afnetworking Pictures
1. Uploading Images
Afhttprequestoperationmanager *manager = [Afhttprequestoperationmanager manager];
Manager.requestserializer = [Afjsonrequestserializer serializer];
Manager.responseSerializer.acceptableContentTypes = [Nsset setwithobject:@ "text/html"];
Nsmutabledictionary *dic=[[nsmutabledictionary alloc] init];
[DiC setobject:@ "Membercenter" forkey:@ "M"];
[DiC setobject:@ "Uploadphoto" forkey:@ "a"];
Nsdictionary *dic = @{@ "M": @ "appraise", @ "a": @ "Doreview"};
Loading pictures
Nsarray *array = @[@ "000", @ "1"];
[Manager post:[nsstring stringwithformat:@ "http://app.sssos.cn/index.php?"] Parameters:dic constructingbodywithblock:^ (id<afmultipartformdata> formData) {
for (int i = 0; i<array.count; i++)
{
UIImage *image=[uiimage Imagenamed:[array objectatindex:i];
NSData *data = uiimagepngrepresentation (image);
[FormData appendpartwithfiledata:data name:@ "filedata[]" filename:[nsstring stringwithformat:@ "%@.png", [array OBJECTATINDEX:I]] mimetype:@ "image/png"];
}
} success:^ (Afhttprequestoperation *operation,id responseobject) {
NSLog (@ "success:%@", responseobject);
} failure:^ (Afhttprequestoperation *operation,nserror *error) {
NSLog (@ "%@", operation.responsestring);
NSLog (@ "error:%@", error);
}];