/    Sign up×
Community /Pin to ProfileBookmark

get_mime_type();

Now that get_mime_type()as a built in function is depricated has anyone written a windows compatible version of this function?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsJul 02.2005 — you can make one easily[code=php]function mimetype($filename)
{
$info = pathinfo($filename);

switch(strtolower($info['extension']))
{
case 'jpg':
return 'image/jpeg';
case 'gif':
return 'image/gif';
case 'png':
return 'image/png';
case 'zip':
return 'application/zip';
case 'gz':
return 'application/gzip';
case 'txt':
return 'text/plain';
// etc.
default:
return 'application/octet-stream';
}
}[/code]
Copy linkTweet thisAlerts:
@bokehauthorJul 02.2005 — Thanks, but that just tells me the extension the file has been saved with, which is a bit trusting to say the least.
Copy linkTweet thisAlerts:
@ShrineDesignsJul 02.2005 — apache's mime types work in the same manner, using the file extension to determine how to handle the file

i know with images and some types of binary files, on the first line contains the text that says what it is, jpeg = JPG, png = PNG, pdf = PDF, etc.
Copy linkTweet thisAlerts:
@bokehauthorJul 02.2005 — This is what I have so far and it does weed out fake files, but I want to add a few more extensions like .MOV and .MPG:
[code=php]
if(!function_exists('mime_content_type')){
function mime_content_type($file){
@$size = GetImageSize($file);
if ($size[mime]){
return($size[mime]);
}
return('application/octet-stream');
}
}

[/code]
×

Success!

Help @bokeh 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 5.7,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...