Re: How to get mime type from file name

From: Date: Mon, 16 Aug 2004 01:56:20 +0000
Subject: Re: How to get mime type from file name
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193911@lists.php.net to get a copy of this message
First of, do not mail me directly, post to the news group! 2nd: http://www.php.net/manual/en/function.mime-content-type.php [snip] mime_content_type (PHP 4 >= 4.3.0, PHP 5) [/snip] Which mean: You need *at least* PHP4.3.0 for this extension. 3rd: http://www.php.net/manual/en/ref.mime-magic.php [snip] Installation You must compile PHP with the configure switch --with-mime-magic to get support for mime-type functions. The extension needs a copy of the simplified magic file that is distributed with the Apache httpd. Note: The configure option has been changed from --enable-mime-magic to --with-mime-magic since PHP 4.3.2 [/snip] Which mean: You need to compile PHP with this switch. 4th: http://pecl.php.net/package/fileinfo From: "C.F. Scheidecker Antunes" <nando@antunes.eti.br> To: Hannes Magnusson <bjori@jeshus.com> CC: php-general@lists.php.net Subject: Re: [PHP] Re: How to get mime type from file name Date: Sun, 15 Aug 2004 18:40:10 -0600 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510 Hannes, Thanks but I have checked the manual as well, my PHP is version 4.3.6 however the function mime_content_type() is not there. Besides that, systems without php 4.3 or higher do not support it. Therefore, maybe I should write a function to read it from /etc/mime.types. Unless there is something easier. Thanks. Hannes Magnusson wrote:What happend to "RTFM" ? Is that not "cool" anymore? http://www.php.net/manual/en/ref.mime-magic.php now, R-T-F-M ! - Hannes On Sun, 15 Aug 2004 18:18:29 -0600 nando@antunes.eti.br (C.F. Scheidecker Antunes) wrote: Hello, Is there any function where I can pass a file name like "file.png" and get return the string of its type 'image/png' ? Basically it is a funcion that takes a file name and returns a string of its mime type. I have used mime_mail to send attachments but the I need when I am attaching the file to know its mime type, for instance a zip file or a jpg or a txt etc. Thanks in advance for the help. On Sun, 15 Aug 2004 18:18:29 -0600 nando@antunes.eti.br (C.F. Scheidecker Antunes) wrote: > Hello, > > Is there any function where I can pass a file name like "file.png" and > get return the string of its type 'image/png' ? > > Basically it is a funcion that takes a file name and returns a string of > its mime type. > > I have used mime_mail to send attachments but the I need when I am > attaching the file to know its mime type, for instance a zip file or a > jpg or a txt etc. > > Thanks in advance for the help.

« previous php.general (#193911) next »