Files
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

42 lines
975 B
PHP

<?php
// Muaz Khan - www.MuazKhan.com
// MIT License - https://www.webrtc-experiment.com/licence/
// Documentation - https://github.com/muaz-khan/RecordRTC
header("Access-Control-Allow-Origin: *");
function selfInvoker()
{
if (!isset($_POST['delete-file'])) {
echo 'PermissionDeniedError';
return;
}
$fileName = $_POST['delete-file'];
$filePath = 'uploads/' . $fileName;
// make sure that one can delete only allowed audio/video files
$allowed = array(
'webm',
'wav',
'mp4',
"mkv",
'mp3',
'ogg'
);
$extension = pathinfo($filePath, PATHINFO_EXTENSION);
if (!$extension || empty($extension) || !in_array($extension, $allowed)) {
echo 'PermissionDeniedError';
return;
}
if (!unlink($filePath)) {
echo ('Problem deleting file.');
} else {
echo ($fileName . ' deleted successfully.');
}
}
selfInvoker();
?>