diff --git a/webinterface/index.php b/webinterface/index.php index 7c55537..8cb1ae2 100644 --- a/webinterface/index.php +++ b/webinterface/index.php @@ -37,19 +37,4 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/webinterface/script.js b/webinterface/script.js index 111ec04..e757188 100644 --- a/webinterface/script.js +++ b/webinterface/script.js @@ -3,15 +3,17 @@ let chunks = []; var mediaRecorder = false; -var sendFile = function (blob) { +var sendFile = async function (blob) { const formData = new FormData(); formData.append('userfile', blob, new Date() + ".webm"); - return fetch('upload.php', { + const response = await fetch('upload.php', { method: 'POST', body: formData }); + + console.log(response.json()) } var initRecording = function (autostart) { diff --git a/webinterface/upload.php b/webinterface/upload.php index 9327530..3aca61d 100644 --- a/webinterface/upload.php +++ b/webinterface/upload.php @@ -6,6 +6,8 @@ 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 "File is valid, and was successfully uploaded.\n"; } else {