fetchAll(); if (empty($ar)) { throw new Exception("Image not found"); } $row = array_shift($q->fetchAll()); $filename = basename($filename); header("Pragma: public"); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private', false); $path = MTrackAttachment::local_path($row['hash']); require_once 'File/MimeType.php'; $y = new File_MimeType(); $mimetype = $y->fromFilename($filename); header("Content-Type: $mimetype"); list($major) = explode('/', $mimetype, 2); if ($major == 'image' || $major == 'text') { $disp = 'inline'; } else { $disp = 'attachment'; } header("Content-Disposition: $disp; filename=\"$filename\""); header('Content-Transfer-Encoding: binary'); header("Content-Length: $row[size]"); readfile($path); exit; } }