How can I download files(text/pdf/etc) using php with a header that pops-up in order for the user to choose Save or Open? The file is stored in (admin/)
I'm using this but it won't work. The downloaded file is empty! Here's my code:
//get the filename
$filename = $_GET['filename'];
//open the file based in filename and path
$fp = fopen('admin/'.$filename, 'w') or die("can't open file");
header("Content-type: text/pdf");
header("Content-Disposition: attachment; filename=file.txt");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
//echo file_get_contents($filename);
exit;