title: Upload photos - Error status code 500 - swift 3
body: <p>I am trying to upload a photo from a UIImage and I am receiving an error statuscode 500, "statusCode should be 200, but is 500", Can someone help with that or maybe give another solution to upload a image file to a server in swift 3? <strong>OR HOW DO I SOLVE THIS USING ALAMOFIRE?</strong></p>
  
  <pre><code>let imageData = UIImageJPEGRepresentation(self.images.firstObject as! UIImage, 0.9)
  
  let myBase64Data = imageData!.base64EncodedString(options: [])
  
  let request = NSMutableURLRequest(url: URL(string: "http://www.example.com/members/mobileapi/uploadSingleFile/")!)
  request.httpMethod = "POST"
  let postString = "username=tiagotest&amp;password=test&amp;bpo_id=248522&amp;encoded_string=\(myBase64Data)&amp;image_name=testFromIphone"
  
  request.httpBody = postString.data(using: String.Encoding.utf8)
  
  let task = URLSession.shared.dataTask(with: request as URLRequest) {
  
      (data, response, error) in
      guard error == nil &amp;&amp; data != nil else {                                                              
          print("error=\(error)")
          return
      }
  
      if let httpStatus = response as? HTTPURLResponse , httpStatus.statusCode != 200 {
          print("statusCode should be 200, but is \(httpStatus.statusCode)")
          print("response = \(response)")
      }
  
      let responseString = String(data: data!, encoding: String.Encoding.utf8)
      print(responseString!)
  }
  task.resume()
  </code></pre>