hi i need help i am using the code below from php.net to allow site visitors download documents on my site
<?php
$file = $_GET['file'];;
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
my problem is that instead of the code outputting a dialog box in order for me to save/download the document as outlined here http://www.php.net/manual/en/function.readfile.php the code opens up in a new page showing abnormal data...the code works perfectly on xampp localhost but not on the server
what might be the problem??