note 38088 added to function.is-uploaded-file

From: Date: Mon, 08 Dec 2003 00:58:26 +0000
Subject: note 38088 added to function.is-uploaded-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-61611@lists.php.net to get a copy of this message
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."); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.is-uploaded-file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38088 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38088&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38088&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61611) next »