这是我目前的代码:
let request = NSMutableURLRequest(URL: NSURL(string: "http://www.example.com/upload.php"))
request.HTTPMethod = "POST"
let postString = "name=\(name)&id=\(id)"
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
data, response, error in
if error != nil {
print("error=\(error)")
return
}
let response = String(data: data!, encoding: NSUTF8StringEncoding)
}
task.resume()
我的图片是myImage.image
。
如何将图片上传添加到上面的代码中?
答案 0 :(得分:0)
尝试这个我希望它会有所帮助!!
Ctrl+B