This code works successfully uploading, but I'd like to redirect from that page after upload. I tried a few things without success:
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( "https://../index.php" );
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 assistance is appreciated