5 * @copyright Copyright (c) 2022-2024 Go Johansson (nokonoko) <neku@pomf.se>
7 * Note that this was previously distributed under the MIT license 2015-2022.
9 * If you are a company that wants to use Uguu I urge you to contact me to
10 * solve any potential license issues rather then using pre-2022 code.
12 * A special thanks goes out to the open source community around the world
13 * for supporting and being the backbone of projects like Uguu.
15 * This project can be found at <https://github.com/nokonoko/Uguu>.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <https://www.gnu.org/licenses/>.
31 require_once __DIR__
. '/../vendor/autoload.php';
32 use Pomf\Uguu\Classes\Upload
;
33 use Pomf\Uguu\Classes\Response
;
35 function handleFiles(string $outputFormat, array $files):void
37 $upload = new Upload($outputFormat);
38 $files = $upload->reFiles($files);
39 $fCount = count($files);
40 $upload->fingerPrint($fCount);
43 while ($i < $fCount) {
44 $res[] = $upload->uploadFile();
52 $resType = (isset($_GET['output']) and !empty($_GET['output'])) ? strtolower(preg_replace('/[^a-zA-Z]/', '', $_GET['output'])) : 'json';
53 $response = new Response($resType);
54 if (!isset($_FILES['files']) or empty($_FILES['files'])) {
55 $response->error(400, 'No input file(s)');
57 handleFiles($resType, $_FILES['files']);