From 01fc3e51ccc02c94630b59073b5597ccac590bfb Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Wed, 13 Jun 2018 14:13:48 +0300 Subject: fix service --- php-src/tests/http/upload.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 php-src/tests/http/upload.php (limited to 'php-src/tests/http') diff --git a/php-src/tests/http/upload.php b/php-src/tests/http/upload.php new file mode 100644 index 00000000..2f7c0b64 --- /dev/null +++ b/php-src/tests/http/upload.php @@ -0,0 +1,35 @@ +getUploadedFiles(); + array_walk_recursive($files, function (&$v) { + /** + * @var \Psr\Http\Message\UploadedFileInterface $v + */ + + if ($v->getError()) { + $v = [ + 'name' => $v->getClientFilename(), + 'size' => $v->getSize(), + 'mime' => $v->getClientMediaType(), + 'error' => $v->getError(), + ]; + } else { + $v = [ + 'name' => $v->getClientFilename(), + 'size' => $v->getSize(), + 'mime' => $v->getClientMediaType(), + 'error' => $v->getError(), + 'md5' => md5($v->getStream()->__toString()), + ]; + } + }); + + $resp->getBody()->write(json_encode($files, JSON_UNESCAPED_SLASHES)); + + return $resp; +} \ No newline at end of file -- cgit v1.2.3