/    Sign up×
Community /Pin to ProfileBookmark

Ok, here’s a bit of a php newbie question.

What’s the best way to determine a file’s type? Given a path to a file, how do I determine whether it’s a .gif, .jpg, .swf, etc?

Jaelan

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsDec 01.2004 — either by the file extension (ex. *.gif), or the mime type (ex. image/gif), the mime type is more reliable than the file extension
Copy linkTweet thisAlerts:
@JaelanauthorDec 02.2004 — Is there any way to get the mime type other than the function: mime_content_type()?

here's my error:

[code=php]
echo mime_content_type($logo); //$logo is defined, and is the path to an image or flash file.
[/code]


It gives the error:

Fatal error: Call to undefined function: mime_content_type() in ....

Jaelan
Copy linkTweet thisAlerts:
@JaelanauthorDec 02.2004 — just a note, too...i'm running php 4.3.2 (an older version, but it should still support the function)

Jaelan
×

Success!

Help @Jaelan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...