Re: how to determine the mime type of a general blob?
| From: | Michael Gauthier | Date: | Mon, 22 Mar 2010 13:07:29 +0000 |
| Subject: | Re: how to determine the mime type of a general blob? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30419@lists.php.net to get a copy of this message | ||
On Fri, 2010-03-19 at 14:08 -0400, Robert P. J. Day wrote:
> i've perused the general PHP site and the PEAR site, and i haven't
> found anything that will let me determine the mime type of a simple
> blob of bytes. everything seems to be based off of the data being in
> a *file*. in my case, it's not in a file, it's simply a stream of
> bytes in a variable, and i'd rather not have to write all that data to
> a file just to identify its mime type.
>
> surely there's something that will tell me the mime type of a string
> of bytes, no?
>
Hi Robert,
What you could do here is use the data:// string wrapper that's
built-into PHP5 (http://www.php.net/manual/en/wrappers.data.php). That
way, you can treat a string as a file resource. It's a bit of a hack,
but it should work.
Alternatively, opening a feature request against the fileinfo extension
in PHP core would be a good idea.
Cheers,
Mike