By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,903 Members | 1,922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,903 IT Pros & Developers. It's quick & easy.

Determining mime type of MySQL blob?

P: n/a
Is there any PHP function that will allow me to determine the MIME type
of a blob stored in MySQL?

Specifically, if I'm storing an image as a blob in MySQL, is there any
PHP function that can determine whether it's a gif, jpeg, png, etc?

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 25 Feb 2004 18:13:18 -0000, Sugapablo <ru********@sugapablo.com> wrote:
Is there any PHP function that will allow me to determine the MIME type
of a blob stored in MySQL?

Specifically, if I'm storing an image as a blob in MySQL, is there any
PHP function that can determine whether it's a gif, jpeg, png, etc?


A fairly naff solution: write it to a file and use:

http://uk2.php.net/manual/en/functio...ntent-type.php

But this is far from a brilliant idea. And it's still only a heuristic anyway;
if possible, write the MIME type into a column next to the blob when you first
write the data?

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #2

P: n/a
Since you are storing it, you should store the type of file it is as well.
mime-types are a list of types to tell other apps what the data was, if we
always looked at the data to find mime-type, then we would need mime-type
lists.

yes, it is possible, but why read and parse data, just store image type when
you store image.

--
Mike Bradley
http://www.gzentools.com -- free online php tools
"Sugapablo" <ru********@sugapablo.com> wrote in message
news:sl***********************@dell.sugapablo.net. ..
Is there any PHP function that will allow me to determine the MIME type
of a blob stored in MySQL?

Specifically, if I'm storing an image as a blob in MySQL, is there any
PHP function that can determine whether it's a gif, jpeg, png, etc?

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]

Jul 17 '05 #3

P: n/a
getimagesize() will return the image type too. See
http://www.php.net/manual/pl/function.getimagesize.php.

If you're running PHP 4.3+, you can avoid writing to a tempfile by
implementing a URL wrapper. The VariableStream class in
http://www.php.net/manual/pl/functio...r-register.php works
pretty well with getimagesize().

Uzytkownik "Andy Hassall" <an**@andyh.co.uk> napisal w wiadomosci
news:gh********************************@4ax.com...
On Wed, 25 Feb 2004 18:13:18 -0000, Sugapablo <ru********@sugapablo.com> wrote:
Is there any PHP function that will allow me to determine the MIME type
of a blob stored in MySQL?

Specifically, if I'm storing an image as a blob in MySQL, is there any
PHP function that can determine whether it's a gif, jpeg, png, etc?
A fairly naff solution: write it to a file and use:

http://uk2.php.net/manual/en/functio...ntent-type.php

But this is far from a brilliant idea. And it's still only a heuristic

anyway; if possible, write the MIME type into a column next to the blob when you first write the data?

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.