Quote:
Originally Posted by SmokeyTheBear
you could use htaccess like this in the folder with the videos
Code:
RewriteEngine on
RewriteRule ^(.*)\.MP4 mp4.php?x=$1 [nc]
this makes all requests for capital letter version "example.MP4" go to a file called mp4.php
Code:
<?php
$x = $_GET['x'];
$file = "$x.mp4";
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
} else {
echo "bad request";
}
?>
|
Do NOT read and print videos in PHP. Similar code in PHP almost always has three major bugs.
Instead set the headers in the .htaccess.
Smokey did manage to halfway avoid one bug, so his implementation has only 2 1/2 major issues. That's definitely better than most people do.
Still remaining is the big which for about a year caused one popular CMS to crash servers fairly regularly and this code too will crash your server when it gets busy. It also has a glaring security hole.