ios - Passing userID with photo POST Swift -
i have upload function sends photo server using post method. want include variable userid (currentuser) in service. have following code, when switch let param = ["userid" : "1"]
let param = [currentuser]
error. currentuser declared string function calls cant figure out whats wrong.
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)
Comments
Post a Comment