let manager = AFHTTPRequestOperationManager(baseURL: NSURL(string: strURL))
print("pram is \(manager)")
manager.requestSerializer = AFJSONRequestSerializer()
manager.responseSerializer = AFJSONResponseSerializer()
// let jsonData = try! NSJSONSerialization.dataWithJSONObject(param!, options: .PrettyPrinted)
let imageData = UIImageJPEGRepresentation(UIImage(named: "placeholder.png")!, 0.5)
let op : AFHTTPRequestOperation = manager.POST("data", parameters: param, constructingBodyWithBlock: { (formData: AFMultipartFormData!) -> Void in
formData.appendPartWithFileData(imageData!, name: "photo", fileName: "photo.png", mimeType: "image/jpeg")
// print(op)
},
success:
{
(operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in
print(responseObject)
},
failure: { (operation, error) in
print("Error: " + error.localizedDescription)
})!
op.start()
}
我尝试使用此代码进行多种形式但返回400
我想像
一样发送{"first_name":"John","last_name":"Doe","dob":"1990-01-02","gender":"M","ph
one_no":"9988475","email":"j.d@gmail.com","password":"john.doe","user_type":"U","facebook_id":""}
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="photo"; filename=""
Content-Type:
----WebKitFormBoundary7MA4YWxkTrZu0gW
我想将我的数据发送到服务器上,就像我发布的内容一样。我试过这个代码来实现,但我不能。请帮助我解决这个问题