func convertImageToBase64(image: UIImage) -> String {
let imageData = UIImagePNGRepresentation(image)
let base64String = imageData?.base64EncodedString(options:.lineLength64Characters)
return base64String!
}// end convertImageToBase64
Swift代码在这里(base 64编码部分):
let base64string = self.convertImageToBase64(image: self.pro_images.image!)
let imgbase64str = base64string.replacingOccurrences(of:"+", with: "%2B")
request.httpMethod = "POST"
let postString = ("email=\(savedValue!)&image=\(imgbase64str)&subject=\(self.analy_title.text!)&content=\(self.analy_text.text!)")
request.httpBody = postString.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) { data, ....
php代码在这里:
if($image != "null"){
if(file_put_contents($upload_path,base64_decode($image))){
我想上传我的base64编码图片 但我无法获得原始图片。 因为图片不显示。 如何解决这个问题?