View Single Post
Old 02-14-2008, 01:11 AM   #7 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Alan @ CIT View Post
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
You're a life saver. :D Sorry but the people who NEED it are getting pissed off. :P

Also, its $_FILES['file']['type'], I then take out image/ and use the others.

Update: Now it says invalid image for me >.<
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote