Here is my answer
Alamofire.upload(multipartFormData: { multipartFormData in
//Single image to pass here
if image != nil{
if let imageData = UIImageJPEGRepresentation(image!, 0.8) {
multipartFormData.append(imageData, withName: "Your key here", fileName: "\(UUID().uuidString).jpeg", mimeType: "image/jpeg")
}
}
//Here array of UIImages
if images.count != 0{
for img in images{
if let imageData = UIImageJPEGRepresentation(img, 0.8) {
multipartFormData.append(imageData, withName: "Your key here", fileName: "\(UUID().uuidString).jpeg", mimeType: "image/jpeg")
}
}
}
//params are your other post parameters
if let parm = params{
for (key, value) in parm {
multipartFormData.append((value as AnyObject).data(using: String.Encoding.utf8.rawValue)!, withName: key)
}
}
}, to: "Your url here" , method: .post, headers: headers,
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
//Success response
case .failure(let encodingError):
//Failure response
}
})