I am Using Swift 3 and want to post an Array of pictures with this method - please help how can I do that
if let imageData = UIImageJPEGRepresentation(customKindImage.image! , 1) {
print("There is Not Any Images to upload!")
let uploadScriptUrl = URL(string : "http://www.swiftdeveloperblog.com/http-post-example-script/")
var request = URLRequest(url: uploadScriptUrl!)
request.httpMethod = "POST"
request.setValue("Keep-Alive" , forHTTPHeaderField : "Connection")
let task = URLSession.shared.uploadTask(with: request, from: imageData, completionHandler: { (data, response, error) in
guard let _ = data, error == nil else {
print(error?.localizedDescription ?? "Error")
return
}
//access data here
})
task.resume()
}
and here is my Array
var photoes : [UIImage] = [
UIImage(named: "1.jpg")!,
UIImage(named: "2.jpg")!,
UIImage(named: "3.jpg")!]