Ios 对成员上传alamofire的引用不明确

Ios 对成员上传alamofire的引用不明确,ios,swift,alamofire,Ios,Swift,Alamofire,我在尝试将图片上载到web服务器时收到此错误。我刚刚从github复制并粘贴了alamofire样本,我马上收到了一个错误。我的代码如下: let data = UIImageJPEGRepresentation(picOutlet.image, 0.5) Alamofire.upload(.POST, "phpurlhere", file: photo) .progress { bytesWritten, totalBytesWritten, totalByte

我在尝试将图片上载到web服务器时收到此错误。我刚刚从github复制并粘贴了alamofire样本,我马上收到了一个错误。我的代码如下:

  let data = UIImageJPEGRepresentation(picOutlet.image, 0.5)


    Alamofire.upload(.POST, "phpurlhere", file: photo)
        .progress { bytesWritten, totalBytesWritten, totalBytesExpectedToWrite in
            print(totalBytesWritten)

            // This closure is NOT called on the main queue for performance
            // reasons. To update your ui, dispatch to the main queue.
            dispatch_async(dispatch_get_main_queue()) {
                print("Total bytes written on main queue: \(totalBytesWritten)")
            }
        }
        .validate()
        .responseJSON { response in
            debugPrint(response)
    }

更新:我添加了JPEG表示以传递给alamofire函数,但仍然得到相同的错误。

问题在于
上传
函数:

Alamofire.upload(.POST, "phpurlhere", file: photo)
对于
文件:
参数,需要类型为
NSURL
的对象。您正在给它一个
UIImage

如果您的目标是使用
upload
功能上载
picOutlet.image
,请尝试以下操作:

let data = UIImageJPEGRepresentation(picOutlet.image, 0.5)

Alamofire.upload(.POST, "phpurlhere", data: data)
    .progress { bytesWritten, totalBytesWritten, totalBytesExpectedToWrite in
        print(totalBytesWritten)

        // This closure is NOT called on the main queue for performance
        // reasons. To update your ui, dispatch to the main queue.
        dispatch_async(dispatch_get_main_queue()) {
            print("Total bytes written on main queue: \(totalBytesWritten)")
        }
    }
    .validate()
    .responseJSON { response in
        debugPrint(response)
}
试试这个

 Alamofire.upload(photoURL, to: "phpurlhere", method: .post, headers:nil)
  .uploadProgress { progress in // main queue by default
            progressView.progress = Float(progress.fractionCompleted)
   }
  .downloadProgress { progress in // main queue by default
     print("Download Progress: \(progress.fractionCompleted)")
  }
  .responseJSON { response in
    debugPrint(response)
  }

您收到了什么错误?对成员上载的引用不明确(::标题:文件:)'为什么在url参数上使用
phpurlhere
而不是url?我只是想删除我的实际web url。请在声明函数的位置共享完整的*.swift文件。在进行更改后,我仍然会收到相同的错误消息。请尽量避免将代码作为答案转储,并尝试解释它的作用和原因。对于没有相关编码经验的人来说,您的代码可能并不明显。