We said that the first way to upload pictures is to transfer the pictures to the image stream to upload; Today we are going to introduce another approach. is to use the method of afnetworking in the use of URLs to upload the way. Concrete backstage how to receive I don't know clearly.
The old words do not say more directly on the code.
Afhttprequestoperationmanager *manager = [Afhttprequestoperationmanager manager];//instantiation AFN
Afjsonresponseserializer *response = [Afjsonresponseserializer serializer];
JSON transfer Mode
Response.removeskeyswithnullvalues = YES;
Manager.responseserializer = response;
Manager.requestserializer = [Afhttprequestserializer serializer];
[Manager Post:url Parameters:
Nsdictionary
Constructingbodywithblock:
(void (^) (id<afmultipartformdata>))
success:^ (afhttprequestoperation * _nonnull operation, id _nonnull responseobject) {
Success (Responseobject);
} failure:^ (Afhttprequestoperation * _nonnull operation, Nserror * _nonnull error) {
Failure (error);
}];
where (void (^) (id<afmultipartformdata>)) is uploaded to the image
The picture can be a single sheet or multiple sheets.
Leaflet: [FormData appendpartwithfiledata:uiimagepngrepresentation (image) name:@ "Images" filename:@ "Name.png" mimetype:@ "Image/png"];
Multiple: This method to do a loop to arrange the picture into a queue;
Note: The Namec parameter must be the same as the background, otherwise the background will not receive