Welcome Guest, Not a member yet? Register   Sign In
Fast way to know if my data is an image or a swf file
#1

[eluser]Rubiz'[/eluser]
Hi all!

I would like to know if PHP has some function or code iginiter has a helper, something like that, that returns me the type of the file.

For exemple: I need show data in a table. But I dont know if this data will be a SWF file or an Image. There's some fast way to know it?
#2

[eluser]ejangi[/eluser]
What I normally do is something like this:

Code:
$filename = 'mygreatfile.swf';
$extension = end(explode('.', $filename));
#3

[eluser]Rubiz'[/eluser]
Cool! I didnt know this end() command
#4

[eluser]Seppo[/eluser]
Easier
Code:
$extension = pathinfo($filename, PATHINFO_BASENAME);
#5

[eluser]Rubiz'[/eluser]
it does not return me the extension name... Seppo, this one yes Smile
Code:
<?

    $filename = "imagem.jpg";
    $extension = pathinfo($filename, PATHINFO_EXTENSION);
    echo $extension;

?>
Very nice this function Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB