My apologies, I led all of you in the wrong direction on this.
Problem comes with this: I want to change the name of an image to
something else.
Let's say I have /images/my_image.jpg
And I want to change it to: /images/my_image.xls
Obviously that would work in PHP but when your browser tries to access
it it would think it's an Excel spreadsheet and not an image and
damage ensues.... or worse, change to: /images/my_image.pif -> YIKES!
Anyway, what I have to do is this: when I decide to change image
metadata such as the image name, I have to be sure that the name that
I change the image name to is an actual "image"-like name, in other
words, if I change it to "my_image.ext" then "my_image.ext" *must* be
of a valid MIME type for an image before it is allowed to change the
name of the image to that name.
And I'm sorry but getimagesize(), in this case, can't help me at all.
Phil
"Chung Leong" <ch***********@hotmail.com> wrote in message news:<V7********************@comcast.com>...
Use getimagesize(). It's much more efficient than going through the "magic"
list when you know you have an image on your hand. The function returns an
array. The 'mime' element gives you the mime-type.
See http://www.php.net/manual/en/function.getimagesize.php
Uzytkownik "Phil Powell" <so*****@erols.com> napisal w wiadomosci
news:1c**************************@posting.google.c om... How do you detect an image MIME type if you know of the image in a
directory? For example, I know of:
[PHP]
if (is_file("$myImagePath/$myImageName")) { // FIND MIME TYPE BUT HOW
I DUNNO
}
[/PHP]
The only way I could think of was to determine the extension of the
image and search through /etc/mime.types, which is horrifically
impractical but the only thing I can think of. What would you suggest
I do?
Thanx
Phil