preview response

main
vitrinekast 1 year ago
parent 88866fb700
commit 1f99151f3c

@ -38,18 +38,3 @@
</body> </body>
</html> </html>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$uploaddir = '/opt/homebrew/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
}
?>

@ -3,15 +3,17 @@ let chunks = [];
var mediaRecorder = false; var mediaRecorder = false;
var sendFile = function (blob) { var sendFile = async function (blob) {
const formData = new FormData(); const formData = new FormData();
formData.append('userfile', blob, new Date() + ".webm"); formData.append('userfile', blob, new Date() + ".webm");
return fetch('upload.php', { const response = await fetch('upload.php', {
method: 'POST', method: 'POST',
body: formData body: formData
}); });
console.log(response.json())
} }
var initRecording = function (autostart) { var initRecording = function (autostart) {

@ -6,6 +6,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$uploaddir = getcwd() . '/uploads/'; $uploaddir = getcwd() . '/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']); $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
// TODO check file type
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n"; echo "File is valid, and was successfully uploaded.\n";
} else { } else {

Loading…
Cancel
Save