From a1177ef83d7436cfcc5bf2bd6f5ca0960c0fd335 Mon Sep 17 00:00:00 2001 From: Cees van Egmond Date: Mon, 9 Oct 2017 09:17:06 +0200 Subject: [PATCH] Bugfix: Correctly strip base64 prefix --- Form/DataTransformer/Base64ToImageTransformer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Form/DataTransformer/Base64ToImageTransformer.php b/Form/DataTransformer/Base64ToImageTransformer.php index c736754..8d1c83f 100644 --- a/Form/DataTransformer/Base64ToImageTransformer.php +++ b/Form/DataTransformer/Base64ToImageTransformer.php @@ -35,8 +35,8 @@ public function reverseTransform($value) return null; } - - $base64 = preg_replace('/data:.*;base64,/', '', $value['base64']); + $prefixLenght = strpos($value['base64'], 'base64,') + 7; + $base64 = substr($value['base64'], $prefixLenght); $filePath = tempnam(sys_get_temp_dir(), 'UploadedFile'); $file = fopen($filePath, 'w');