You can do it with afnetwroking
-(void)saveServerData:(UIImage *)image{
NSData *imageToUpload = UIImageJPEGRepresentation(image, 1.0);
if (imageToUpload)
{
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
GameId, @"gameid"
, useremail, @"userid"
, PartIndex, @"imageposition"
, nil];
NSString *url=[NSString stringWithFormat:@"%@addplayerresponse",BASE_URL];
AFHTTPClient *client= [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:url]];
NSLog(@"%@",parameters);
NSMutableURLRequest *request = [client multipartFormRequestWithMethod:@"POST" path:url parameters:parameters constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
[formData appendPartWithFileData: imageToUpload name:@"image" fileName:[NSString stringWithFormat:@"%@_%@.jpeg",appDelegate.userid,appDelegate.onlineGameId] mimeType:@"image/jpeg"];
}];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
// NSDictionary *jsons = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
NSLog(@"Response:%@",parameters);
//success
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
if([operation.response statusCode] == 403)
{
return;
}
NSLog(@"error: %@", [operation error]);
}];
[operation start];
}
}
And i don't think you can upload folder either you have to upload one image at a time or you have to make zip the folder and send it, and in the php you have to unzip it after saving it.