Re: PHP to get File Type

From: Date: Tue, 14 Oct 2008 15:29:43 +0000
Subject: Re: PHP to get File Type
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-281892@lists.php.net to get a copy of this message
> function get_file_extension($file) { http://us2.php.net/manual/en/function.pathinfo.php <?php $path_parts = pathinfo('/www/htdocs/index.html'); echo $path_parts['dirname'], "\n"; echo $path_parts['basename'], "\n"; echo $path_parts['extension'], "\n"; echo $path_parts['filename'], "\n"; // since PHP 5.2.0 ?> Secondly the MIME type can differ from the extension (file suffix) It's the same with uploaded files. Although the browser sends the MIME type it might not be the right one, since browsers obtain the MIME by checking the extension. //A yeti

« previous php.general (#281892) next »