Re: Setting the filetype!
| From: | Kevin Beckford | Date: | Fri, 23 Jun 2000 16:16:03 +0000 |
| Subject: | Re: Setting the filetype! | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2814@lists.php.net to get a copy of this message | ||
This code gives the extension as $matches[2]. You can then check to see what
the extension is and code for whatever
function check_ext($_file)
{
if(preg_match("/(\.[^.]*)*(\..+$)/",$_file,$matches));
{
return $matches;
}
return "false";
}
$test=check_ext($filename);
if ($test[2] == .gif || $test[2} == .jpg)
{
$icon = "<IMG SRC=\"image.gif\" alt=\"Image\"
border=\"0\" width=\"16\"
height=\"16\">";
$browse = "1";
$raw = "0";
$image = "1";
}
This code gives the extension as $matches[2]. You can then check to see what
the extension is and code for whatever. It's a code snippet of something that
I'm working on, so that's why I am using index 2 as the final extension.
HTH
Kevin