how to display show get file extension getting uploaded file extension type
how to display show get file extension getting uploaded file extension type
how, to, display, show, get, file, extension, getting, uploaded, file, extension, type


Fri Feb 29, 2008 12:01 pm - how to display show get file extension getting uploaded file extension type
#1854
how to display show get file extension getting uploaded file extension type
author: web hosting
Leave Your Comments
name
comments
Share
Share this post by copy and paste this URL and put it on your forums or use it on your profile like myspace, friendster, Facebook, Twitter or others and add in with your comments.
URL Link: ask
Use this HTML code to embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it.
Embed: ask
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on with Posts and Replies on your forums
BBCODE: ask
| More
Sun Jul 15, 2007 5:18 pm - Re: how to display show get file extension getting uploaded file extension type
#2078
maca
thanks, this was good to know how to remove the file extension on a string i was working on.
Sun Jul 15, 2007 5:29 pm - Re: how to display show get file extension getting uploaded file extension type
#2079
webune
another way to do this, i use this php code:

PHP CODE:
$filename = 'wallpaperama.jpg';
preg_match('/.([A-Za-z]+?)$/', $filename, $matches);
echo "The file exension for $filename is: ".$matches[1]."
and with the dot is ".$matches[0]."";
?>



OUTPUT:

The file exension for wallpaperama.jpg is: jpg
and with the dot is .jpg



courtesy: Webune hosting
Sun Jul 15, 2007 5:41 pm - Re: how to display show get file extension getting uploaded file extension type
#2080
hostman
that was a good one, and another way is to split the file name and the file extension into an array with this function:

function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
$filename = 'wallpaperama.jpg';
echo '

'.findexts ($filename).'


';
?>


OUTPUT:
The File Extension is: jpg


anyone else has a way to display the file name and the extension into an array?

Sun Jul 15, 2007 6:00 pm - Re: how to display show get file extension getting uploaded file extension type
#2081
maca
i would like to learn that, you know, split the file into the filne name and the file extension into two separate string, well, i was able to figure out how to get the file name and remove the extension from the file name with this fucntion:

I use this function to remove the file extension and display only the file name without the extension of the file name: this is good when you have users upload files and you can rename the to whatever you want and then display them on the website with the new name:

<?
function remove_ext($filename) {
$extension = strrchr($filename, '.');
if($extension !== false){
$filename = substr($filename, 0, -strlen($extension));
}
return $filename;
}
$filename = 'wallpaperama.jpg';
echo remove_ext($filename);
?>


OUTPUT:

The file name without extension is: wallpaperama