@aussie_girlJul 11.2006 — #OMG how many ways is there to do this and which do you guys feel is the most efficiant and effective!! i need to limit them to .wma and .jpg[/QUOTE]
[code=php] $allowed = array ('image/jpeg', 'image/jpg', 'image/pjpeg'); if (in_array($_FILES['upload']['type'], $allowed)) { // Move the file to the correct directory..else error message //Not sure about the wma, but this is for images [/code]
The mime type of the file, if the browser provided this information. An example would be "image/gif". This mime type is however not checked on the PHP side and therefore don't take its value for granted. [/quote] Therefore, if you're concerned about users "sneaking" invalid file types in, simply checking the type as above or checking the file name's suffix will not be sufficient. You would actually need to read the header information from the file to determine what type it really is. For image files, this can be done with the [url=http://www.php.net/exif_imagetype]exif_imagetype() function[/url]. I don't know if there's anything similar for .wma files.
@bokehJul 11.2006 — #OMG how many ways is there to do this and which do you guys feel is the most efficiant and effective!! i need to limit them to .wma and .jpg[/QUOTE]Are you talking about limiting uploads? Or something else? Your question doesn't explain too well.
@bokehJul 12.2006 — #well getimagesize() returns false if a file is not an image. For certain other files that follow a strict format it is possible to access the first few bytes of the file and see if they correspond with the file format.