How to make browser download a file (binary) through php?
Posted: Mon Jun 02, 2003 11:22 am
Right now I have in file getfile.php
This code is causes IE to display the "File Download" window, but it also shows another window on top that says "Internet Explorer cannot download file getfile.php?ID=7 from http://www.my-site.com". I have double checked the path, and its correct. I know because if I remove the header() line, the binary stuff in the file is shown in the explorer window.
Anybody know what error I'm making and how to fix it?
Thanks.
Code: Select all
<?
// some code to get the filename from a db
// and $_GET['file_id'] is used to query db
//create filename with path
$file="../../../downloads/".$db_row['filename'];
//send headers
header("Content-Type: application/pdf");
readfile($file);
?>Anybody know what error I'm making and how to fix it?
Thanks.