Ios 通过照片传递用户ID

Ios 通过照片传递用户ID,ios,string,post,Ios,String,Post,我有一个上传功能,使用POST方法将照片发送到我的服务器。我现在还想在这个服务中包含一个变量userID(currentUser)。我有下面的代码,但是当我将let-param=[“userId”:“1”]切换到类似let-param=[currentUser]的位置时,我得到了一个错误。currentUser被声明为一个字符串,这是函数调用的字符串,因此我无法真正找出错误所在 func myImageUpLoadRequest(){ let myUrl = NSURL(stri

我有一个上传功能,使用POST方法将照片发送到我的服务器。我现在还想在这个服务中包含一个变量userID(currentUser)。我有下面的代码,但是当我将
let-param=[“userId”:“1”]
切换到类似
let-param=[currentUser]
的位置时,我得到了一个错误。currentUser被声明为一个字符串,这是函数调用的字符串,因此我无法真正找出错误所在

func myImageUpLoadRequest(){
        let myUrl = NSURL(string: "http://server.com/POSTTEST/imageUpload.php");

        let request = NSMutableURLRequest(URL:myUrl!);
        request.HTTPMethod = "POST";

        let param = ["userId" : "1"]

        let boundary = generateBoundaryString()

        request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")

        let imageData = UIImageJPEGRepresentation(myImageView.image, 1)

        if(imageData==nil)  { return; }

        request.HTTPBody = createBodyWithParameters(param, filePathKey: "imagefile", imageDataKey: imageData, boundary: boundary)