Jump to content

PHP Directory Handling -- Videos : NEED HELP


techiefreak05

Recommended Posts

Hello, I am going to offer a video hosting service on my site, similiar to Google Video. I was wondering how I could handle the directory of the videos, like when a user uploads a video, it uploads it into "/uploads/videos", and when a user goes to "uploads/videos" it has a list of all the vidoes uploaded(like the user that uploaded that file, date uploaded, etc..).... instead of the regular directory view thingy... Thanks for your help!!

--Brenden
Link to comment
Share on other sites

Do you have a database that you can use for this?  Or are you already logging the uploads to some sort of file.  If you don't have a database you can use a file to log the uploads, but that could eat away at page load times.

The basic method I would use in this case is to start by creating an "index.php" page in the video upload directory.  That way when a person goes to that folder they will see that page instead of a file list.  Since I don't know your situation I'll finish off with a quick overview of the rest of the method until you provide the rest of the details:

There are two ways to do this depending on if you only want to show files with info or if you want to show all files and include info if possible.  The former would simple require you to pull all rows from the database and list them out.  That will give a list of all files that are currently logged as uploaded.  The latter would use scandir() to get a filelist, and then for each file, query the database (the filename would be the primary key), and if a row is returned, output that info.  Otherwise it is a file with no info and you can simply display a link and output "No Info".  There are some other combinations of these methods that would produce other effects.  Let me know what your situation is and how you are looking to make it work and I can detail a specific method further.
Link to comment
Share on other sites

you could write a function to scan a directory for videos, I've used this one in the past, feel free to edit to your needs, this one return all the flv files which are flash video

[code]
function getVideos() {

$path = $_ENV['DOCUMENT_ROOT'];
$d = $path.'/videos/';
$dir = opendir($d);
while ($f = readdir($dir)) {
if (eregi("\.flv",$f))
$files[]=$f;
}
return $files;
}
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.