Reputation: 419
I am able to send post data as json fine from swift using this code:
private func alamoFireAjax(url: String, parameters: Parameters, callback: @escaping (DataResponse<Any>) -> Void) {
Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseJSON(completionHandler: callback)
}
But I want to send a image along with the data that this function is sending. How do I do that in alamofire, or do I need a different framework.
Upvotes: 0
Views: 140
Reputation: 506
You need convert(encode) image to base64 and send to PHP as a string, after receiving post PHP can decode it and save in the storage or save base64 string.
Upvotes: 3