Jump to content

Forced Download?


spires

Recommended Posts

Hi Guys

 

Can some one please take a look at me code, as point me in the right direction.

 

I'm trying to get a link, to force a .mov download.

http://www.adwordstool.co.uk/test2.php

 

But, I can't seem to get it to work.

 

Here's my code.

<?php
if ($_GET['name']){
$file = 'http://www.adwordstool.co.uk/videos/tools/'.$_GET['name'];
header( 'Expires: Mon, 1 Apr 1974 05:00:00 GMT' );
header( 'Pragma: no-cache' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Content-Description: File Download' );
header( 'Content-Type: application/octet-stream' );
header( 'Content-Length: '.filesize( $file ) );
header( 'Content-Disposition: attachment; filename="'.basename( $file ).'"' );
header( 'Content-Transfer-Encoding: binary' );
readfile( $file );
}  
?>

<a href="test2.php?name=split_testing.mov" class="minitext">Split Testing</a>

 

 

Any help would be great

Thanks

Link to comment
https://forums.phpfreaks.com/topic/134671-forced-download/
Share on other sites

Hi Guys

 

I have worked out how to force the download:

http://www.adwordstool.co.uk/test2.php

 

$file_name = $_GET['name'];

$file = 'videos/tools/'.$file_name;
     header("Expires: 0");
     header("Cache-Control: public");
     header("Content-Description: File Transfer");
     header("Content-Type: application/force-download");
     header("Content-Disposition: attachment; filename=".basename($file));
				header( "Content-Description: File Transfer");
@readfile($file);

 

However, When I download the file, it's not recognizing that it's downloaded a .mov file.

I can't open the file in quicktime.

 

 

Any ideas???

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/134671-forced-download/#findComment-701259
Share on other sites

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.