2019-08-25 21:45:52 +02:00
|
|
|
<?PHP
|
2019-08-30 23:14:18 +02:00
|
|
|
declare(strict_types = 1);
|
2020-10-31 00:00:26 +01:00
|
|
|
require_once __DIR__ . "/../functions/functions.php";
|
2019-08-30 23:14:18 +02:00
|
|
|
|
2020-11-08 14:30:14 +01:00
|
|
|
if (empty($_FILES)) {
|
|
|
|
throw new MDFileDoesNotExist("No file uploaded");
|
|
|
|
}
|
|
|
|
|
2020-07-03 16:41:31 +02:00
|
|
|
$targetpart = basename($_FILES['uploaded']['name']);
|
2020-11-08 14:30:14 +01:00
|
|
|
$target = __DIR__ . "/../csv/" . $targetpart;
|
|
|
|
|
|
|
|
// TODO: File name needs to be sanitized, or tmp name used
|
2020-07-03 16:41:31 +02:00
|
|
|
|
2020-07-03 17:54:40 +02:00
|
|
|
if (session_status() != PHP_SESSION_ACTIVE) {
|
|
|
|
session_start();
|
|
|
|
}
|
|
|
|
|
2020-12-10 00:49:46 +01:00
|
|
|
if (MD_STD_SEC::validateAntiCsrfToken() === false) {
|
2020-09-15 23:11:38 +02:00
|
|
|
throw new MDWrongCsrfTokenException();
|
2020-07-03 16:41:31 +02:00
|
|
|
}
|
2020-01-28 19:01:33 +01:00
|
|
|
|
2019-08-27 00:31:46 +02:00
|
|
|
//This is our size condition
|
2020-11-08 14:30:14 +01:00
|
|
|
if ($_FILES['uploaded']['size'] > 40000000) {
|
2019-08-27 00:31:46 +02:00
|
|
|
echo "Your file is too large.<br>";
|
2019-08-30 23:14:18 +02:00
|
|
|
return;
|
2019-08-27 00:31:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Here we check that $ok was not set to 0 by an error
|
2019-08-30 23:14:18 +02:00
|
|
|
//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;
|
2019-08-25 21:45:52 +02:00
|
|
|
}
|
2019-08-30 23:14:18 +02:00
|
|
|
|
2020-07-21 23:48:39 +02:00
|
|
|
header("Location: index3.php?fnam=" . basename($_FILES['uploaded']['name']));
|