View Single Post
Old 2008-05-06, 09:10 PM   #1
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
.htaccess
Code:
RewriteEngine on
RewriteRule vids/(.*) /video.php?video=$1 [L]
video.php
Code:
<?php
  $filename = "/var/www/domain.com/" . $_REQUEST['video'];
  if ( (preg_match("/[a-z0-9\-_]+.(mp4|wmv|mp4a)/i",$_REQUEST['video'])) && 
       (file_exists($filename)) ) {
  header("Content-Type: " . mime_content_type($filename));
  header('Content-Disposition: attachment; filename="' . $_REQUEST['video'] . '"');
  $file=fopen($filename,"rb");
  fpassthru($file);
  close($file);
  } else {
    print "error retrieving file";
  }
?>
Not a lot of error checking in it, file paths will need to be changed, but, this is probably the basics of what you're looking for. Mimetype detection will help, you can fix the preg_match to match the extensions you want to allow. filenames cannot contain more than one . and must be comprised of all letters, numbers, - and _.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote