title: Error in uploadng image using alamofire
body: <p>I am trying to upload image using Alamofire. But application is crashing when I try to make the app rquest with following message:</p>
  
  <blockquote>
    <p>-[<strong>NSCFNumber dataUsingEncoding:]: unrecognized selector sent to instance 0xb000000000000013
    2018-02-20 00:19:58.167574+0530 ProSales[63550:5801521] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber dataUsingEncoding:]: unrecognized selector sent to instance 0xb000000000000013'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x0000000104ea812b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x0000000103feff41 objc_exception_throw + 48
        2   CoreFoundation                      0x0000000104f29024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
        3   CoreFoundation                      0x0000000104e2af78 ___forwarding_</strong> + 1432
        4   CoreFoundation                      0x0000000104e2a958 _CF_forwarding_prep_0 + 120
        5   ProSales                            0x0000000103125b03 _T08ProSales17NetworkOperationsC11uploadImageySS3url_s10DictionaryVySSyXlG5paramSo7UIImageC5imageyAA6ResultOc17completionHandlertFZy9Alamofire17MultipartFormDataCcfU_ + 1011
        6   ProSales                            0x0000000103125de3 _T08ProSales17NetworkOperationsC11uploadImageySS3url_s10DictionaryVySSyXlG5paramSo7UIImageC5imageyAA6ResultOc17completionHandlertFZy9Alamofire17MultipartFormDataCcfU_TA + 99
        7   Alamofire                           0x0000000103688c74 _T09Alamofire14SessionManagerC6uploadyyAA17MultipartFormDataCc09multipartfG0_s6UInt64V14usingThresholdAA21URLRequestConvertible_p4withyAC0efG14EncodingResultOcSg18encodingCompletiontFyycfU_ + 212
        8   Alamofire                           0x000000010368c59c _T09Alamofire14SessionManagerC6uploadyyAA17MultipartFormDataCc09multipartfG0_s6UInt64V14usingThresholdAA21URLRequestConvertible_p4withyAC0efG14EncodingResultOcSg18encodingCompletiontFyycfU_TA + 156
        9   Alamofire                           0x0000000103611269 _T0Ix_IyB_TR + 41
        10  libdispatch.dylib                   0x0000000109d1b2f7 _dispatch_call_block_and_release + 12
        11  libdispatch.dylib                   0x0000000109d1c33d _dispatch_client_callout + 8
        12  libdispatch.dylib                   0x0000000109d283a2 _dispatch_root_queue_drain + 1444
        13  libdispatch.dylib                   0x0000000109d27da0 _dispatch_worker_thread3 + 132
        14  libsystem_pthread.dylib             0x000000010a1e35a2 _pthread_wqthread + 1299
        15  libsystem_pthread.dylib             0x000000010a1e307d start_wqthread + 13
    )
    libc++abi.dylib: terminating with uncaught exception of type NSException</p>
  </blockquote>
  
  <p>Code for uploading the image:</p>
  
  <pre><code>class func uploadImage(url:String, param:[String:AnyObject], image:UIImage, completionHandler: @escaping CompletionHandlerType){
      let imageData: Data = UIImagePNGRepresentation(image)!
      Alamofire.upload(multipartFormData:{ multipartFormData in
          multipartFormData.append(imageData, withName: "image",fileName: "image.png", mimeType: "image/png")
          for (key, value) in param {
              multipartFormData.append(value.data(using: String.Encoding.utf8.rawValue)!, withName: key)
          }
      },
           to:url,
           method:.put,
           headers:getHeader(),
           encodingCompletion: { encodingResult in
              switch encodingResult {
              case .success(let upload, _, _):
                  upload.responseJSON { response in
                      debugPrint(response)
                      completionHandler(.Success(true))
                  }
              case .failure(let encodingError):
                  print(encodingError)
              }
      })
  }
  </code></pre>
  
  <p>I am adding the parameter as following:    </p>
  
  <pre><code>    if !name.isEmpty{
          parameters["name"] = name as AnyObject
      }
      if !email.isEmpty{
          parameters["email"] = email as AnyObject
      }
      if !password.isEmpty{
          parameters["password"] = password as AnyObject
      }
      if !mobile.isEmpty{
          parameters["mobile"] = mobile as AnyObject
      }
  </code></pre>