I have searched, promise! great site btw.
I work for a small video production company and we often post work in progress to our website for clients to check out and comment on. I do this by encoding a video, uploading to our server and creating a static page, embedding the video in a player on the page, it's a fairly laborious and long winded process I'm sure you'll agree.

I would like to streamline this process, I have set up my video encoder to automatically ftp my files to a folder on my server and I would like to create a script that will build pages based on the contents of that folder eg, If I upload a file called dave.flv I could then go to a page called www.dave.com/dave and see a web page with the movie title wrapped in a h1 at the top, the date it was uploaded and the video.
My limited experiencetells me php can help here, any pointers would be massively appreciated.

I have searched, promise! great site btw.
I work for a small video production company and we often post work in progress to our website for clients to check out and comment on. I do this by encoding a video, uploading to our server and creating a static page, embedding the video in a player on the page, it's a fairly laborious and long winded process I'm sure you'll agree.

I would like to streamline this process, I have set up my video encoder to automatically ftp my files to a folder on my server and I would like to create a script that will build pages based on the contents of that folder eg, If I upload a file called dave.flv I could then go to a page called www.dave.com/dave and see a web page with the movie title wrapped in a h1 at the top, the date it was uploaded and the video.
My limited experiencetells me php can help here, any pointers would be massively appreciated.

you want to start out with something like this:

<?php
$strDir = "myUploadsDir";
$arrFileInfo = array();

foreach(scandir($strDir) as $strFileName)
{
	if(trim($strFileName) == "." || 
		trim($strFileName) == ".." || 
		is_dir($strDir . "/" . $strFileName) || 
		!file_exists($strDir . "/" . $strFileName)) 
		continue;
	
	$arrFileParts = pathinfo($strFileName);
	
	$arrFileInfo[$strFileName] = $arrFileParts["extension"];
}
?>

which will give you an array of key being the file name and value being the extension. Now you have name and filetype of every file in your directory. Now I would do something like this:

<?php
asort($arrFileInfo); //sorts by extension
$arrAllowedExt = array("flv", "mov", "swf", "pdf", "doc"); //make sure we are prepared for unknown filetypes

foreach($arrFileInfo as $key=$value)
{
	if(!in_array($value, $arrAllowedExt)) continue;
	
	?><a href="daves<?php echo strtoupper($value); ?>s.php?fn=<?php echo $key; ?>">Click here to view</a>
	<?php
}
?>

and then on davesFLVs.php or davesSWFs.php or whatever, you just write your code to pull in the $_GET variable and show your movie. Keep in mind, this is an EXTREMELY dumbed down version of how I would do this and wouldn't even think of putting this up without some well thought out security. For one example, on the page that you link to, you need to confirm that the $_GET file is exactly the actual file that you want to show the user. You do this with the file_exists function and make sure that you hard code the directory name and file extension when you do. If you are unsure about whether what you are doing is secure or not, that is a sign to do some research.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.