I have a process allowing the admin to view users information and download files that the user uploaded to MySQL.
When the admin clicks on the file link in the admin page, I expect the file will display using the default program (i.e. pdf or txt), or download (i.e. MSWord).
The admin panel is at:
The files listed can be retreived and viewed using right-click -> save as -> change the ext to the correct type, but when I single-left click the link, I get binary screen output.
I am suspecting a mime-type issue, but do not know enough about this area.
Any suggestions would be great.
Thanks in advance,
<? //error_reporting(E_ALL); //ini_set('display_errors', '1'); include "../contact/reg_dbc.php"; $id = $_GET['id']; $query = "SELECT name, type, size, content " . "FROM subscribers WHERE id = '$id'"; $result = mysql_query($query) or die('Error, query failed'); list($name, $type, $size, $content) = mysql_fetch_array($result); header("Content-type: $type"); header("Content-length: $size"); header("Content-Disposition: attachment; filename=$name"); header("Content-Description: PHP Generated Data"); echo $content; mysql_close(); exit; ?>
P.S. I have this posting in PHP as well, but it seems more appropriate in this forum.