note 38088 deleted from function.is-uploaded-file by didou

From: Date: Mon, 08 Dec 2003 09:42:23 +0000
Subject: note 38088 deleted from function.is-uploaded-file by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-61612@lists.php.net to get a copy of this message
Note Submitter: matt@mattjacob.org ---- This is in response to info@metaltoad.net. Regular expressions are a bad way to check for valid file extensions. Why fire up the regex engine when you can just use PHP's native string-handling functions? <?php $valid_ext = array('.gif', '.jpg', '.png', '.tif', '.eps', '.bmp'); $file_ext = strtolower(substr($_FILES['file']['name'], -4)); if (!in_array($file_ext, $valid_ext)) { exit("Non-image file types aren't allowed."); } ?>

« previous php.notes (#61612) next »