Jump to content

$_REQUEST with force download


the_oliver

Recommended Posts

Hello,

 

Im using this code forom the code snipits bit of the forum, but cant work out how to enter the file name?

 

I tried

$file = $_REQUEST['/var/www/html/file.mp3']

 

but it gave me the error:

Notice: Undefined index: /var/www/vhosts/qrecords.co.uk/httpdocs/PumpUpThePirates.mp3 in /var/www/html/file.mp3 on line 2

 

Can anyone help?  Many Thanks.

 

 

<?php

// force to download a file
// ex, ( [url=http://localhost/php/download.php?file=C:/Apache]http://localhost/php/download.php?file=C:/Apache[/url] Group/Apache2/hongkong.php )
// hope this can save your time :-)

$file = $_REQUEST['file'];

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 

header("Content-Type: application/force-download");
header( "Content-Disposition: attachment; filename=".basename($file));

header( "Content-Description: File Transfer");
@readfile($file);

?>

Link to comment
https://forums.phpfreaks.com/topic/60767-_request-with-force-download/
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.