upload form: file types
Moderator: General Moderators
upload form: file types
my upload form should only allow jpegs to be uploaded but the following code keeps identifying jpegs as *not jpegs*:
if ($_FILES['uploadImage']['type'] == "image/jpeg"){
//continue with upload
}
else{
//error handling
}
i double checked the mime for jpeg and that is correct and should cover all alternatives such as jpg jpe and jpeg but i continually get thrown to the else clause.
if ($_FILES['uploadImage']['type'] == "image/jpeg"){
//continue with upload
}
else{
//error handling
}
i double checked the mime for jpeg and that is correct and should cover all alternatives such as jpg jpe and jpeg but i continually get thrown to the else clause.
Do not rely on $_FILES[...]['type']. The value is take from the client's input.
If I like I can send an executable and mark it as mage/jpeg. Your script would buy it.
Use getimagesize, exif_imagetype or mime_content_type instead
http://de2.php.net/getimagesize
http://de2.php.net/exif_imagetype
http://de2.php.net/mime_content_type
If I like I can send an executable and mark it as mage/jpeg. Your script would buy it.
Use getimagesize, exif_imagetype or mime_content_type instead
http://de2.php.net/getimagesize
http://de2.php.net/exif_imagetype
http://de2.php.net/mime_content_type
went with the mime_content_type, uncommented:
extension=php_mime_magic.dll
and added in:
mime_magic.debug = On
mime_magic.magicfile = "C:\Program Files\EasyPHP1-8\php\magic.mime"
still getting a call to undefined function tho at runtime.
if (mime_content_type($filename) == "image/jpeg"){
//blah
}
else{
//blahblah
}
extension=php_mime_magic.dll
and added in:
mime_magic.debug = On
mime_magic.magicfile = "C:\Program Files\EasyPHP1-8\php\magic.mime"
still getting a call to undefined function tho at runtime.
if (mime_content_type($filename) == "image/jpeg"){
//blah
}
else{
//blahblah
}
Calldoes it refelect the changes you made to the php.ini?
Change something else, display_errors e.g. Does phpinof() reflect that change?
Code: Select all
<?php phpinfo(); ?>Change something else, display_errors e.g. Does phpinof() reflect that change?