From 1f99151f3ced6ada82c17d502f94176b3e35a0d3 Mon Sep 17 00:00:00 2001 From: vitrinekast Date: Mon, 4 Dec 2023 16:08:57 +0100 Subject: [PATCH] preview response --- webinterface/index.php | 17 +---------------- webinterface/script.js | 6 ++++-- webinterface/upload.php | 2 ++ 3 files changed, 7 insertions(+), 18 deletions(-) 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 {