csvxml/upload.php
Joshua Ramon Enslin ef638ee9c4 Fix bug in crsf token handling
phpcs-errors:238 phpunit-status:successful
2020-07-03 17:54:40 +02:00

47 lines
1.2 KiB
PHP

<?PHP
declare(strict_types = 1);
require_once __DIR__ . "/functions/functions.php";
$target = "csv/";
$target .= basename($_FILES['uploaded']['name']);
$targetpart = basename($_FILES['uploaded']['name']);
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
if (validateAntiCsrfToken() === false) {
throw new WrongCsrfTokenException();
}
//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;
}
echo printHTMLHead();
echo "
<div>
<p>The file has been uploaded: <b>" . basename( $_FILES['uploaded']['name']) . "</b>.</p>
<hr />
<h3>How to proceed?</h3>
<ul class='actionList'>
<li><a href='index4.php?fnam=" . basename( $_FILES['uploaded']['name']) . "'>Create XML (utf-8)</a></li>
<li><a href='index3.php?fnam=" . basename( $_FILES['uploaded']['name']) . "'>Check validity for museum-digital import</a></li>
</ul>
</div>
</body>
</html>
";