Reputation: 784
I need to check if the file which exist is the flash file or the image file, so i can put the file in Object tag or img tag respectively.
Upvotes: 0
Views: 244
Reputation: 635
You can use this code to get extensions of files from its file name. And can check this file is image or flash using Conditional statement IF as below
<?php
$filename ="file.jpg";
$ext = strtolower(array_pop(explode('.',$filename)));
if ($ext=='swf'){
echo "flash";//set your object as flash
}
else{
echo "image";//set your object as img
}
?>
Upvotes: 1
Reputation: 177
You can simply use $_FILES['file_name']['type']; and it will return you file type that you can check alternatively you can use
list($width, $height, $type, $attr) = getimagesize("profilepic/".$db_question_data[$lpcntrl]['Photo']);
it will also return you file type of tile in $type variable. Hope this help :)
Upvotes: 1
Reputation: 3986
You can use pathinfo
for this like below:
<?php
$path_parts = pathinfo($filepath);
echo $path_parts['extension']; // You can get the file extension for this
?>
Upvotes: 0