Php 快速上传图像,服务器回复称文件不存在';这不是图像吗?

Php 快速上传图像,服务器回复称文件不存在';这不是图像吗?,php,json,swift,alamofire,Php,Json,Swift,Alamofire,正在进行Swift项目,显然我上传的文件不是图像。我也在使用Alamofire实用程序 let uuid = NSUUID().UUIDString print ("MARK -- UUID is " + uuid) let image = imageView.image Alamofire.upload(.POST, "{RETRACTED}", multipartFormData: { multipartFormData in if

正在进行Swift项目,显然我上传的文件不是图像。我也在使用Alamofire实用程序

let uuid = NSUUID().UUIDString
    print ("MARK -- UUID is " + uuid)
    let image = imageView.image

    Alamofire.upload(.POST, "{RETRACTED}", multipartFormData: {
        multipartFormData in
        if  let imageData = UIImageJPEGRepresentation(image!, 0.6) {
            multipartFormData.appendBodyPart(data: imageData, name: uuid, fileName: uuid + ".png", mimeType: "image/png")
        }
        }, encodingCompletion: {
            encodingResult in

            switch encodingResult {
            case .Success(let upload, _, _):
                upload.responseJSON { response in
                    print(response.request)  // original URL request
                    print(response.response) // URL response
                    print(response.data)     // server data
                    print(response.result)   // result of response serialization

                    if let JSON = response.result.value {
                        print ("JSON \(JSON)")
                        self.displayAlert("Uploaded!", message: "{RETRACTED}", responseButtonText: "{RETRACTED}")
                    }
                }

            case .Failure(let encodingError):
                print(encodingError)
            }
    })
以下是JSON响应(如果需要,我还有PHP服务器端代码):

JSON{ response=“该文件不是图像(仅接受.png和.jpg/.jpeg图像)。类型为”; 响应代码=0; }


谢谢大家。

您发送的是jpg图像,但指定了png的mime类型。将mime类型更改为“image/jpeg”或发送png文件。

您正在发送jpg图像,但指定png的mime类型。将mime类型更改为“image/jpeg”或发送png文件