Only last image in array uploads with Alamofire Swift 3

I need to upload several images to an API at a time. I am using Alamofire to upload images and the API only allows one image to be uploaded per request.

I have an array of images to be uploaded and I am going through the array and making a request each time. Each image appears to upload correctly but then when I check the database only the last image has been uploaded. Each call prints a response with status code 200 and prints “SUCCESSFUL” when it is complete, but only the last in the array actually uploads.

for (index, image) in self.imageArray.enumerated() {
        self.uploadImages(photoIndex: index, photo: image.image, fileName: image.imageName, completion: { (true) in
            print("SUCCESSFUL")
        })
}

I have also tried using a DispatchQueue, but that didn’t work either:

 let serialQueue = DispatchQueue(label: "serialQueue")

And inside the for loop

serialQueue.async {
 //self.uploadImages...
}

I’ve tried a few more things, with no success. How would I be able to fix this?

Use multipart form data to upload the any media file below is the code snippet to upload multiple video

for (key , value) in arrMediaUpload {
                        if let image = value as? UIImage {
                            if let imageData = UIImageJPEGRepresentation(image,0.9) {
                                print("key => /(key)")
                                multipartFormData.append(imageData as Data, withName: key, fileName: "/(NSDate().timeIntervalSince1970).jpg", mimeType: "image/*")
                            }
                        }
                    }