Let's say I have a session variable
$username = $_SESSION['userUid'];
Can I add it as a string to the filename before upload it?
if (!empty($_FILES['uploaded_file'])) {
$allowed = array("video/mp4", "video/webm", "video/ogg");//Allowed types
$file_type = $_FILES['uploaded_file']['type'];
$path = "../videos/";
$path = $path . basename($_FILES['uploaded_file']['name']);
if (!in_array($file_type, $allowed)) {
header("location:../add-video.php?lesson=" . $lesson . "&alert=wrongtype");
}
if (file_exists($path)) {
header("location:../add-video.php?lesson=" . $lesson . "&alert=alreadyexist");
} elseif (in_array($file_type, $allowed) && !file_exists($path)) {
move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path);
echo "The file " . basename($_FILES['uploaded_file']['name']) .
" has been uploaded"; // if checks are successful upload the file
So in the videos directory, I will have something like that: uer345video.mp4