Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-11-2003, 07:35 PM   PM User | #1
optimism_
New Coder

 
Join Date: Jan 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
optimism_ is an unknown quantity at this point
Getting mime-type from file (or its .ext)

I am pretty sure this can be done as it is mentioed in the docs (but as always, it talks mainly about UNIX !!)
Is there a built-in function that will return the mime-type in the form "text/plain" based upon the filedata or extension of a file on the server.
I have tried the mime_content_type(String filename) function, but an undefined function error is returned when i try to use it on my win32 system.

Failing the existance of a built in function, how easy would it be to write one, assuming the default file extensions for all mime types??

Thx
__________________
<?XML version="1.0" standalone="Yes" encoding="utf-8"?>
<SIGNITURE>
XML is the future - embrace it
</SIGNITURE>
optimism_ is offline   Reply With Quote
Old 03-11-2003, 11:06 PM   PM User | #2
Dylan Leblanc
Regular Coder

 
Join Date: Sep 2002
Location: British Columbia
Posts: 235
Thanks: 0
Thanked 0 Times in 0 Posts
Dylan Leblanc is an unknown quantity at this point
If nothing else you could make an array of all MIME types (or at least all the ones you need to deal with), and do something like this:

PHP Code:
$allcontenttypes = array(
    
'png' => 'image/png',
    
'pdf' => 'application/pdf'
);


$fileextension substr($filename, -3);

$contenttype $allcontenttypes[$fileextension]; 
Dylan Leblanc is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:15 AM.


Advertisement
Log in to turn off these ads.