When using PHP with a different server than the Java server
[FormData appendpartwithfiledata:uiimagejpegrepresentation (_pharray[i], 0.1f) name:@ "file[]" filename:[nsstring stringwithformat:@ "%@.png", FileName] mimetype:@ "Multipart/form-data"];
The name parameter cannot be set to @ "file" needs to be set to "file[]" otherwise the server will not resolve to the file array can only resolve the last picture
The specific code is as follows:
#pragmaMark-Send data-(void) postdata {nsmutabledictionary*infodic =[Nsmutabledictionary dictionary]; Nsdictionary* Para =[Nsdictionary dictionary]; Para= @{@"Info": infodic.jsonstring}; NSString* URL =@"filesupload.php"; Afhttpsessionmanager*manager =[Afhttpsessionmanager Manager]; Manager.responseserializer= [AfhttpresponseserializerNew]; [Manager post:[nsstring stringWithFormat:@"%@%@", Exile_base_api,url] Parameters:para constructingbodywithblock:^ (ID<AFMultipartFormData>_nonnull FormData) { if(_pharray.count) { for(inti =0; i<_pharray.count; i++) {NSString*filename = [NSString stringWithFormat:@"%.f_%d", [[NSDate date]timeintervalsince1970],i]; [FormData appendpartwithfiledata:uiimagejpegrepresentation (_pharray[i],0.1f) Name:@"file[]"Filename:[nsstring stringWithFormat:@"%@.png", FileName] MimeType:@"Multipart/form-data"]; }}} Progress:nil success:^ (Nsurlsessiondatatask * _nonnull task,ID_nullable Responseobject) {Nsdictionary*dic =[nsjsonserialization jsonobjectwithdata:responseobject options:nsjsonreadingmutablecontainers Error:nil]; NSLog (@"Response ==>%@", DIC); } Failure:^ (Nsurlsessiondatatask * _nullable task, Nserror *_nonnull Error) {Exile_alert (nil, error.localizeddescription)}];}
[IOS] Server use PHP when multiple picture upload afnetworking settings