02-14-2008, 01:09 AM
|
#6 (permalink)
|
|
The Frequenter
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
|
What does $type actually contain after you have uploaded a file? Your substr() starts checking at character 6, and returns 12 characters which I'm guessing won't match much.
If $type just contains the file extension (without the .), then substr($type) would do it. If it contains the full filename, then you could use substr($type, -3) to get the last 3 characters of the filename (likely the extension).
Alternativly, use the pathinfo() function on the filename to get the extension:
PHP Code:
$file = '/home/www/images/myimage.jpeg';
$fileParts = pathinfo($file);
echo $fileParts['extension'];
// echo's: jpeg
Alan
|
|
|