The code I'm using on a web page allows the visitor to record a video via web cam and then when Upload is selected the recorded file arrives into the /uploads folder successfully. I'm trying to add a redirect to another page after the successful upload, but I added in the 'header(Location ...' and 'exit' lines, (line 20 & 21) it doesn't reditect. Here is the code:
Any guidance/assistance is appreciated.
PHP:
<?php
foreach (array('video', 'audio') as $type) {
if (isset($_FILES["${type}-blob"])) {
$fileName = $_POST["${type}-filename"];
$uploadDirectory = 'uploads/' . $fileName;
// make sure that one can upload only allowed audio/video files
$allowed = array(
'webm',
'wav',
'mp4',
'mov'
);
$extension = pathinfo($uploadDirectory, PATHINFO_EXTENSION);
if (!$extension || empty($extension) || !in_array($extension, $allowed)) {
echo 'Invalid file extension: '.$extension;
return;
}
$new_filepath = "uploads/" . uniqid() . ".". $extension;
header('Location: https://some-website.com');
exit();
if(file_exists($_FILES["${type}-blob"]["tmp_name"]) && is_uploaded_file($_FILES["${type}-blob"]["tmp_name"]))
{
if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $new_filepath))
{
echo 'No upload';
} else {
echo 'File uploaded';
}
}
}
}
?>
Any guidance/assistance is appreciated.