<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title > Upload to the archive< / title >
< link rel = "stylesheet" href = "style.css" >
< / head >
< body >
< div class = "container recorder" >
< canvas width = "800px" height = "800px" style = "display: none" > < / canvas >
< header >
< h1 > Signal lost archive unzipped< / h1 >
< p > some info on what this even < a href = "#" class = "fn-open-dialog-info" > is< / a > < / p >
< span class = 'fn-error' > < / span >
< / header >
< button class = 'fn-start-recording button--record' >
< / button >
< a href = "" class = "fn-open-dialog-form" > Upload a file instead< / a >
< audio controls > < / audio >
< / div >
< dialog class = 'fn-dialog-info' >
< form method = "dialog" class = 'dialog__close' >
< button class = "button--icon" >
< svg xmlns = "http://www.w3.org/2000/svg" height = "24" viewBox = "0 -960 960 960" width = "24" >
< path d = "m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z" / >
< / svg >
< / button >
< / form >
< h3 > Info< / h3 >
< p > Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla nobis eligendi earum assumenda iste ratione, blanditiis cupiditate natus non labore voluptatibus nostrum animi voluptatum ut quibusdam excepturi sit cumque molestiae?< / p >
< form method = "dialog" >
< button class = "" >
close
< / button >
< / form >
< / dialog >
< dialog class = 'fn-dialog-form' >
< form method = "dialog" class = 'dialog__close' >
< button class = "button--icon" >
< svg xmlns = "http://www.w3.org/2000/svg" height = "24" viewBox = "0 -960 960 960" width = "24" >
< path d = "m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z" / >
< / svg >
< / button >
< / form >
< form enctype = "multipart/form-data" class = "fn-upload-form" action = "upload.php" method = "POST" >
< label for = "file" > Select a file to upload< / label >
< input name = "userfile" id = "file" type = "file" / >
< input type = "submit" value = "Send File" / >
< / form >
< / dialog >
< script type = "text/javascript" src = "script.js" > < / script >
< / body >
< / html >
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$uploaddir = getcwd() . '/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
// TODO check file type
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo json_encode("File is valid, and was successfully uploaded.\n");
} else {
echo json_encode("Possible file upload attack!\n");
}
}
?>