I have tried so many method but image is not uploading to server
var params = [String:AnyObject]()
params["profile_picture"] = displayPhoto.image
AF.upload(
multipartFormData: { (multipartFormData) in
for (key, value) in params {
multipartFormData.append((value as! String).data(using:String.Encoding.utf8)!, withName: key)
}
if let imageData = self.displayPhoto.image?.jpegData(compressionQuality: 0.5) {
multipartFormData.append(imageData, withName: "profile_picture", fileName: "file.jpeg", mimeType: "image/jpeg")
}
}, to: "http://ms.XXX/regester",usingThreshold: UInt64.init(),method: .post,headers: nil).responseJSON{
response in
switch response.result {
case .success:
print(response)
let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "homeVC") as? HomeVC
self.navigationController?.pushViewController(vc!, animated: true)
break
case .failure(let error):
print(error)
break
}}
I have tried many stackoverflows method but unable to solve the issue please clarify my error im selecting image from the gallery