且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用AFNetworking将图像上传到服务器已损坏

更新时间:2022-05-05 21:25:26

1)(任务,错误) - > Void in 打印错误(如果存在),因为如果出现问题,您会收到错误。

1) In (task, error) -> Void in print error if it exists, because if something goes wrong you receive error there.

NSLog("%@", error.localizedDescription)

2)您确定名称:1是否写入?因为这是后端获取文件数据的字段名称(询问后端开发人员的此字段名称)

2) Are you sure that name: "1" is write? Because this is the name of field where the backend get the file data (ask about this field name your backend developer)

3)将文件类型 jpeg 附加到上传图片名称:

3) Append file type jpeg to uploading image name:

formData.appendPartWithFileData(imageData, name: "1", fileName: "userimage\(self.objManager.userID).jpeg", mimeType: "image/jpeg")