PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
the only absolute way (for images) is use [php_man]getimagesize[/php_man]() This will determine if it's a valid (appearing) image of any of the types it knows. If it doesn't know it, it'll return FALSE.
Or check the file type when you upload it - $FILES['form_field_name']['type'] - and it will give the type such as image/gif, image/jpeg etc and you just check this value.
yes kettle_drum, your right. But they can change the extension of say a rar file to jpeg, and upload it. But what feyd is saying is that getimagesize() will check the file and make sure it is actually an image or not.
You can change the extension type, but that doesnt change the mime type - which is what is held in the type element of the array - at least i dont believe you can change it.
no, to make sure it has an image extension your going to want to find the extension of the file and check it with your extensions you want. Search this forum on finding the extension for hte file, it'd been mentioned several times the last few days.