title: how to send image in byteArray with parameters in JSON format iOS swift4
body: <p>I am a beginner to iOS and I am having a only a lot less knowledge on programming. Now, in my project I got stuck with a task where I have to send the data of a user being created along with the uploading image for camera or from photo library. Actually I don't know how to do that, I have searched the internet, stackoverflow &amp; some other blogs on how to send images with parameters in swift4 and trying to understand the process still and I have been trying this for a week I don't know what else to do. I am posting my code Here: </p>
  
  <pre><code> @IBAction func createAccountTapped(_sender: UIButton!) {
  
          guard let image = profileImgView.image else {return}
  
          let imageData = UIImageJPEGRepresentation(image, 0.7)
          print(imageData!)
  
          let byteArray = Array(imageData!)
  
          let updateProfileUrl = "http://isit.beetlerim.com/api/UsersAPI/UpdateUserProfile"
  
          let parameters = [
              "UserName":userNameTF.text!,
              "Password":passwordTF.text!,
              "UserTypeId":2,
              "profilePic":"\(arc4random()).jpg",
              "profileImage":byteArray,
              "DOB":dateOfBirthTF.text!,
              "PhoneNumber":phoneNumberTF.text!,
              "Mobile":phoneNumberTF.text!,
              "Email":emailAddressTF.text!,
              "AddressLine1":address1TF.text!,
              "AddressLine2":address2TF.text!,
              "City":cityTF.text!,
              "State":stateTF.text!,
              "Country":countryTF.text!,
              "ZipCode":zipcodeTF.text!
              ] as [String : Any]
  
          let jsonData = try? JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)
  
          print(jsonData!)
  
          // create post request
          let url = URL(string: updateProfileUrl)!
          var request = URLRequest(url: url)
          request.httpMethod = "POST"
  
          // insert json data to the request
          request.httpBody = jsonData
          request.setValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type")
          request.addValue("application/json", forHTTPHeaderField: "Accpet")
          let task = URLSession.shared.dataTask(with: request) { data, response, error in
              guard let data = data, error == nil else {
                  print(error?.localizedDescription ?? "No data")
                  return
              }
              let responseJSON = try? JSONSerialization.jsonObject(with: data, options: .allowFragments )
              if let responseJSON = responseJSON as? [String: Any] {
                  print(responseJSON)
              }
          }
  
          task.resume()
      }
  </code></pre>
  
  <p>I am getting responseJSON : ["message":An error has occurred.]
  }</p>
  
  <p>I have tried many other ways also.. none of them worked neither.. 
  please help me guys:</p>