Well I'm trying to get file output through a control script to work, so that I can make sure a user has permissions to view that file... But its just not working - its seeing the file size, its outputing the information, but its just not showing up... Its always an improper image and I'm wondering why....
My code:
<?php
ob_start();
include_once('functions.inc.php');
include_once("header.inc.php");
if(isset($_GET['id'])) {
$id = $_GET['id'];
$sql = "SELECT * FROM files WHERE id='$id'";
$result = $mysql->query($sql,"get_file");
$file = $mysql->fetch_row('get_file');
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Transfer-Encoding: binary");
header("Content-length: $file[size]");
header("Content-type: $file[mime]");
header("Content-Disposition: attachment; filename=$file[name]");
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
set_time_limit(0);
$filename = $exact_dir."/uploaded/".$file[id]."_".$file[name];
$filename = realpath($filename);
@readfile($filename);
exit;
}
ob_flush();
?>
The file exists and all that as well, heres what size, mime, and name are:
Size: 59300
Mime: image/pjpeg
Name: 1832-b.jpg
What could be going wrong here?