View Single Post
Old 02-14-2008, 01:09 AM   #6 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

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
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
Orc (02-14-2008)