Move public files to /public subdirectory

phpcs-errors:221 phpunit-status:successful phpstan-errors:0
This commit is contained in:
2020-10-31 00:00:26 +01:00
committed by Stefan Rohde-Enslin
parent 00f1c4f423
commit d56601b0cc
19 changed files with 62 additions and 30 deletions

29
public/upload.php Normal file
View File

@ -0,0 +1,29 @@
<?PHP
declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php";
$target = __DIR__ . "/../csv/" . basename($_FILES['uploaded']['name']);
$targetpart = basename($_FILES['uploaded']['name']);
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
if (validateAntiCsrfToken() === false) {
throw new MDWrongCsrfTokenException();
}
//This is our size condition
if ($uploaded_size > 40000000) {
echo "Your file is too large.<br>";
return;
}
//Here we check that $ok was not set to 0 by an error
//If everything is ok we try to upload it
if(!move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
echo "Sorry, there was a problem uploading your file.";
return;
}
header("Location: index3.php?fnam=" . basename($_FILES['uploaded']['name']));