note 104520 added to function.finfo-buffer
| From: | contact at ingnu dot fr | Date: | Mon, 20 Jun 2011 21:22:04 +0000 |
| Subject: | note 104520 added to function.finfo-buffer | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180796@lists.php.net to get a copy of this message | ||
You can easily check mime type of an internet resource using this code :
<?php
function getUrlMimeType($url) {
$buffer = file_get_contents($url);
$finfo = new finfo(FILEINFO_MIME_TYPE);
return $finfo->buffer($buffer);
}
?>
I'm using it to detect if an url given by a user is a HTML page (so I do some stuff with the
HTML) or a file on Internet (so I show an icon accordingly to the mime type).
----
Server IP: 69.147.83.197
Probable Submitter: 82.231.65.89
----
Manual Page -- http://www.php.net/manual/en/function.finfo-buffer.php
Edit -- https://master.php.net/note/edit/104520
Del: integrated -- https://master.php.net/note/delete/104520/integrated
Del: useless -- https://master.php.net/note/delete/104520/useless
Del: bad code -- https://master.php.net/note/delete/104520/bad+code
Del: spam -- https://master.php.net/note/delete/104520/spam
Del: non-english -- https://master.php.net/note/delete/104520/non-english
Del: in docs -- https://master.php.net/note/delete/104520/in+docs
Del: other reasons-- https://master.php.net/note/delete/104520
Reject -- https://master.php.net/note/reject/104520
Search -- https://master.php.net/manage/user-notes.php