title: Uploading image with Almofire 4 swift 3
body: <p>i want to upload photo into server with almofire i'm using this code right now but i'm getting timeout</p>
  
  <pre><code>let imageData = UIImageJPEGRepresentation(croppedImage, 1)
  
  let urlRequest = self.urlRequestWithComponents(url, imageData: imageData!)
  self.alamofire.upload(urlRequest.1, to: urlRequest.0 as! URLConvertible).responseJSON { response in
      guard response.result.isSuccess else {
          self.showError()
          return
      }
  
      guard let data = response.result.value else {
          self.showError()
          return
      }
  
      let json = JSON(data)
  }
  
  func urlRequestWithComponents(_ urlString:String, imageData:Data) -&gt; (URLRequestConvertible, Data) {
      var urlRequest = URLRequest(url: URL(string: urlString)!)
      urlRequest.httpMethod = HTTPMethod.post.rawValue
      let boundary = generateBoundaryString()
      let contentType = "multipart/form-data;boundary=" + boundary
      urlRequest.setValue(contentType, forHTTPHeaderField: "Content-Type")
  
      let uploadData = NSMutableData()
  
      uploadData.append("\r\n--\(boundary)\r\n".data(using: String.Encoding.utf8)!)
      uploadData.append("Content-Disposition: form-data; name=\"file\"; filename=\"file.png\"\r\n".data(using: String.Encoding.utf8)!)
      uploadData.append("Content-Type: image/png\r\n\r\n".data(using: String.Encoding.utf8)!)
      uploadData.append(imageData)
      uploadData.append("\r\n--\(boundary)--\r\n".data(using: String.Encoding.utf8)!)
  
      return try! (Alamofire.URLEncoding.default.encode(urlRequest, with: nil), uploadData as Data)
  }
  </code></pre>
  
  <p>Is there any solution about this issue ?</p>