the_oliver Posted July 19, 2007 Share Posted July 19, 2007 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 More sharing options...
chigley Posted July 19, 2007 Share Posted July 19, 2007 $file = "/var/www/html/file.mp3"; Link to comment https://forums.phpfreaks.com/topic/60767-_request-with-force-download/#findComment-302301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.