doupu1957 2017-06-05 13:49
浏览 93
已采纳

如何将POST Json和Image发送到php alamofire

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.

  • 写回答

1条回答 默认 最新

  • duan19740319 2017-06-05 13:52
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?