ライブラリalamofireを使用してイメージファイルをサーバーに送信できません。私は画像ファイルを動的に送信することに問題があります。ファイル名はサーバに表示されますが、画像は空です。どのように解決できますか?サーバに画像を送信できませんか?
画像コード
let parameters = [
"name": name_txt.text! as String,
"address": address_txt.text! as String,
"district": website_txt!.text! as String,
"country": establishment_txt.text! as String,
]
Alamofire.upload(multipartFormData: { multipartFormData in
if let imageData = UIImageJPEGRepresentation(self.logo_holder.image!, 1) {
multipartFormData.append(imageData, withName: "logo", fileName: "file.png", mimeType: "image/png")
}
for (key, value) in parameters {
multipartFormData.append((value.data(using: .utf8))!, withName: key)
}}, to: "http://www.myeducationhunt.com/api/v1/schools", method: .post, headers: ["Authorization": "auth_token"],
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.response { [weak self] response in
guard self != nil else {
return
}
debugPrint(response)
}
case .failure(let encodingError):
print("errorss:\(encodingError)")
}
})
私はblank.Howなくなって画像のファイル名が、画像を受信することができています。この を解決することができますか?
以下の問題の解決http://stackoverflow.com/questions/41021802/alamofire-4-and-swift-3-image-uploadを確認してください試すことができます-with-other-parameters –
申し訳ありませんが、私はこれを既にチェックしました。ありがとう –