/** * Takes a file and returns its mime type * * @author Scott Blake * @param string $filename * @return string **/ public static function getMimeType($filepath) { if (isPHP('5.3')) { $fi = new finfo(FILEINFO_MIME_TYPE); return $fi->file($filepath); } $fi = new finfo(FILEINFO_MIME); list($mimeType, $mimeEncoding) = explode(';', $fi->file($filepath)); return $mimeType; }
// Show the combined PDF's thumbnail // Find the file that has an image mime type foreach ($fileArray['files']['combine'] as $file) { if (FALSE !== strpos($file['type'], 'image/')) { $filepath = files::getSaveDir($fileUUID, 'combine') . $file['name']; break; } } } } // Make sure the file exists if (!file_exists($filepath)) { throw new Exception('File not found! "' . $filepath . '"'); } // Get the MIME Type if (isPHP('5.3')) { $fi = new finfo(FILEINFO_MIME_TYPE); $mimeType = $fi->file($filepath); } else { $fi = new finfo(FILEINFO_MIME); list($mimeType, $mimeEncoding) = explode(';', $fi->file($filepath)); } // Set the correct MIME-Type headers, and output the file's content if (isset($engine->cleanGet['MYSQL']['download']) and str2bool($engine->cleanGet['MYSQL']['download'])) { header(sprintf("Content-Disposition: attachment; filename='%s'", isset($downloadFilename) ? $downloadFilename : basename($filepath))); header("Content-Type: application/octet-stream"); ini_set('memory_limit', -1); die(file_get_contents($filepath)); // die so nothing else will be displayed } else { if ($mimeType == 'application/x-empty') {