/    Sign up×
Community /Pin to ProfileBookmark

Download with link

Is there a way i can download a video right away without having the guest to right click? Can anyone help me?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@pcthugOct 01.2006 — Save the following code as [I]download.php[/I], save it in the directory where all your videos are located. To access a file use the following format:
<i>
</i>http://www.yourdomain.com/path/to/video/dir/download.php?file=[color=red]video_filename.mpg[/color]
[code=php]
<?php

$filename = dirname(__FILE__) . '/' . $_GET['file'];

// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');

$pathinfo = pathinfo($filename);

if($filename == dirname(__FILE__) . '/') {
exit('No filename specified.');
}

elseif(!file_exists($filename) || strpos($filename, '../') {
exit('No such file exisits');
};

switch( $file_extension ) {
case 'avi': $ctype = 'video/x-msvideo'; break;
case 'mov': $ctype = 'video/quicktime'; break;
case 'mpeg':
case 'mpg': $ctype= 'video/mpeg'; break;
case 'ra': $ctype = 'video/x-pn-realaudio'; break;
case 'ram' : $ctype = 'video/x-pn-realaudio'; break;
case 'wmv': $ctype= 'video/windowsmedia';
default: $ctype="video/force-download";
}

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename="" . basename($filename) . "";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($filename));
readfile($filename);
exit();

?>[/code]
Copy linkTweet thisAlerts:
@Luke101authorOct 04.2006 — thanks
×

Success!

Help @Luke101 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...