Close Panel
Hello Guest! | Log In


lheader.gif rheader.gif
tgcontentlogo.gif
tgcontentlogob.gif

PHP: Get File Extension

There are many ways to get the file extension of a file. Here is an example of a php function I found to do just that.

<?php
function file_extension($fname)
{
$path_info = pathinfo($fname);
return $path_info[‘extension’];
}
?>

Another way would be to check the actual string and use what’s after the last slash. I picked this up on a forum I visit.

<?php
$filetype = substr($file, strrpos($file, ‘.’) + 1);
?>

2 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


29 user(s) currently online (0 members, 29 guests, 0 anonymous)
No Members Logged In



lhfooter.gif
Valid XHTML 1.0 | Valid CSS | Load Time: 0.575343 sec(s)
rfooter.gif