Hello everyone,
I currently have this code which displays all of the files of extention .flv or .swf and then passes the file to a video player on another page. To pass the video I need to include _ between words as the file name. I was wondering if anyone can help me edit this so that it will pass this over as it is now but the link that is displayed to the user to click on has the video file name but with the spaces there instead of the underscores. I also don't want to display the extention to the user which it is currently doing.
Thank you.
<?php # Script 13.8 - view_videos.php
// This is the login page for the site.
// Include the configuration file for error management and such.
require_once ('./includes/config.inc.php');
// Set the page title and include the HTML header.
$page_title = 'View Video Tutorials';
include ('./includes/header.html');
$current_dir = "includes/videos/"; // Location to read files from.
$dir = opendir($current_dir); // Opens the directory.
echo ("<p><h1>Video Tutorials:</h1></p><hr><br />");
while ($file = readdir($dir)) // while loop
{
$parts = explode(".", $file); // pull apart the name and dissect by period
if (is_array($parts) && count($parts) > 1) { // does the dissected array have more than one part
$extension = end($parts); // set to we can see last file extension
if ($extension == "flv" OR $extension == "swf"){ // Set allowable file extensions.
echo "<a href=video_player.php?video=$file> $file </a><br />"; // Link to location of video.
}
}
}
echo "<hr><br />";
closedir($dir); // Close the directory.
include ('./includes/footer.html');
?>