Share Coding

Tutorials, Problems, Stuffs …

Tag Archives: file

Serve a file without Direct Link on PHP

Some videos wanted to stream to iPhone, but seems IOS do not support RTMP protocol.
But if those videos exposed on direct link, anyone can download it directly (Insecure).
Thus, the following example is a solution that serve a file without direct link to itself.


$file = '/usr/local/videos/video.mp4';
$mime_type = "video/mp4";
if ( is_file($file) ) {
	header("Content-type: $mime_type");
	if( isset($_SERVER['HTTP_RANGE']) ) {
	} else {
		header("Content-Length: " . filesize($file));
} else {
	// some error...

Read more of this post