<?php


session_start();   
$isvalid = false;
$newFileName = '';
if(!isset($_SESSION['tfbs'])){
     
}else if($_SESSION['tfbs'] == null){
    
   
    
}else{
     $isvalid = true; 
}

?>
<?php
 
 if($isvalid){
     

  $message = ''; 
  if (isset($_FILES['uploadedVid']) && $_FILES['uploadedVid']['error'] === UPLOAD_ERR_OK)
  {
    // get details of the uploaded file
    $fileTmpPath = $_FILES['uploadedVid']['tmp_name'];
    $fileName = $_FILES['uploadedVid']['name'];
    $fileSize = $_FILES['uploadedVid']['size'];
    $fileType = $_FILES['uploadedVid']['type'];
    $fileNameCmps = explode(".", $fileName);
    $fileExtension = strtolower(end($fileNameCmps));
 
    // sanitize file-name
    $newFileName = md5(time() . $fileName) . '.' . $fileExtension;
    $newFileName =$fileName;
 
    // check if file has one of the following extensions
    $allowedfileExtensions = array('mp4');
 
    if (in_array($fileExtension, $allowedfileExtensions))
    {
      // directory in which the uploaded file will be moved
      $uploadFileDir = "../vid/";
      $dest_path = $uploadFileDir . $newFileName;
 
      if(move_uploaded_file($fileTmpPath, $dest_path)) 
      {
        $message ='File is successfully uploaded.';
      }
      else
      {
        $message = 'There was some error moving the file to upload directory. Please make sure the upload directory is writable by web server.';
      }
    }
    else
    {
      $message = 'Upload failed. Allowed file types: ' . implode(',', $allowedfileExtensions);
    }
  }
  else
  {
    $message = 'There is some error in the file upload. Please check the following error.<br>';
    $message .= 'Error:' . $_FILES['uploadedVid']['error'];
  }
echo $newFileName; 
     
     
      }else{
     
 }

?>