note 77697 deleted from features.file-upload by felipe

From: Date: Sun, 30 Dec 2007 17:56:58 +0000
Subject: note 77697 deleted from features.file-upload by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134337@lists.php.net to get a copy of this message
Note Submitter: ash at atomic-network dot co dot uk ---- I have always wanted to just allow image files; and found using an array which would work on IE, FF, And Opera etc. would be to define the "image/name" for all of those. as IE is "image/x-name" and FF is "image/name" etc. <?php function image_valid($type) { $file_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/jpeg' => 'jpeg', 'image/gif' => 'gif', 'image/X-PNG' => 'png', 'image/PNG' => 'png', 'image/png' => 'png', 'image/x-png' => 'png', 'image/JPG' => 'jpg', 'image/GIF' => 'gif', 'image/bmp' => 'bmp', 'image/bmp' => 'BMP', ); if(!array_key_exists($type, $file_types)) { return "FALSE"; } else { return "TRUE"; } } if(image_valid($_FILES['user_file']['type']) === "FALSE") { die("Image file is not valid"); } ?>

« previous php.notes (#134337) next »