summaryrefslogtreecommitdiffstats
path: root/mimetype.php
blob: 1134a132fe7453236c5dd7b2da0d5f4142a8f3b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/php
<?php

// Return mimetype of file
function mimetype($file) {
	$fileinfo = new finfo(FILEINFO_MIME_TYPE);

	// XXX: Workaround for PHP#71434 https://bugs.php.net/bug.php?id=71434
	$old = error_reporting();
	error_reporting($old &~ E_NOTICE);
	$mimetype = $fileinfo->file($file);
	error_reporting($old);

	return $mimetype;
}

printf("%s\n", mimetype($argv[1]));
printf("%s\n", mime_content_type($argv[1]));