Jump to content

how to stream video via ftp folder not accessable to public


jasonc

Recommended Posts

edited:  please note all wmv files are not more than 10 or 20 seconds long. also their size is no more than 500kb.

 

 

I have this following code that works for photos, but wish to alter this slightly so it will work for video files (wmv)

 

getFtpImage.php

<?
header('Content-Type: image/jpg');
					$imgdir = '/home/mysite/ftpfolder';
					readfile($imgdir . '/' . $_GET['file']);
?>

 

 

index.php

$imgdir = '/home/mysite/ftpfolder'; // the directory, where your images are stored
							$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show
							$dimg = opendir($imgdir);
							while($imgfile = readdir($dimg)) {
								if(in_array(strtolower(substr($imgfile,-3)),$allowed_types)) {
								$a_img[] = $imgfile;
								sort($a_img);
								reset ($a_img);
								}
							}

							$totimg = count($a_img); // total image number
								for($x=0; $x < $totimg; $x++) {
								$size = getimagesize($imgdir.'/'.$a_img[$x]);
								// do whatever
								$halfwidth = ceil($size[0]/2);
								$halfheight = ceil($size[1]/2);
								?><img src="getFtpImage.php?file=<? echo ($a_img[$x]); ?>" height="180"><?
								// echo 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />';
								}

 

i have the images show to fill the screen and wish for the video page to do the same and with the videos you click the [play] in the center of the video image to play it like most videos play, not like the flash.

i have a load of photos and videos and the photos script (above) works and show the images, i am using the getFtpImage.php file to get the content of the image as it is in a folder outside of the public_html folder.

 

i also have WMV files in this outside ftpfolder and wish to allow the user to click a link to play the file in their browser.

 

i would normally use the embed method but as it is not an image that can be got using the getFtpImage.php file i need another method to allow the WMV to play.

Now I'm with you.

 

You need to rewrite another script (almost a copy of getFtpImage.php) that sets the content type to video/x-ms-wmv (you could use the same script with an if statement that determines the types by file extension.

 

From there, you just use the normal embed method.

 

I have to say, wmv files are not a particularly 'web friendly' format.

ok i did that using you helpful piece of info about the file type text.

 

only problem is that i get a down load box when i click the link, is there an embed or method i can use that will show the thumb nail of the first image?  a bit like flash?

 

<?
header('Content-type: video/x-ms-wmv');
				$imgdir = '/home/mysite/ftpfolder';
				readfile($imgdir . '/' . $file);
?>

Archived

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

×
×
  • 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.