From 32be24336740b7fca6c286694a60fa4502c5328d Mon Sep 17 00:00:00 2001 From: pensiero Date: Tue, 14 Feb 2017 17:41:12 +0100 Subject: [PATCH] Fixed API create when source is an url --- src/ImageUploader/Controller/Api.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ImageUploader/Controller/Api.php b/src/ImageUploader/Controller/Api.php index 14f7d7b..02e897f 100644 --- a/src/ImageUploader/Controller/Api.php +++ b/src/ImageUploader/Controller/Api.php @@ -95,8 +95,12 @@ private function create(): array { // source passed via JSON request if ($_SERVER['CONTENT_TYPE'] == 'application/json') { + $data = json_decode(file_get_contents('php://input'), true); - $source = base64_decode($data['source']); + + $source = filter_var($data['source'], FILTER_VALIDATE_URL) + ? $data['source'] + : base64_decode($data['source']); } // source uploaded else if (!empty($_FILES)) {