Jump to content

Archived

This topic is now archived and is closed to further replies.

techiefreak05

PHP Directory Handling -- Videos : NEED HELP

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

Share this post


Link to post
Share on other sites
*bump*

Anyone?? anyone at all? Well, yeah I guess it IS 5 AM .. so I really shouldnt expect too much replies.. :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
I dont have a database.. but if I should. then I will, I mean people will just upload videos to my site and it will automatically be displayed at the index.php in the video uploads folder...with a link to that video..

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Thanks!! Well, now how do I get a new window to pop-up when a link to a movie is clicked? The window will have the video file and play it.

Share this post


Link to post
Share on other sites
Another thing, how do I get a ranking thing on that pop-up window where the video plays? Like, my rating code will automatically appear on every video page.

Share this post


Link to post
Share on other sites

×

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.