note 37328 added to function.move-uploaded-file

From: Date: Tue, 11 Nov 2003 01:02:44 +0000
Subject: note 37328 added to function.move-uploaded-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-60222@lists.php.net to get a copy of this message
Here is a much better, reliable function to check the extension of an uploaded file: <?php function checkext($filename, $search) { if (stristr(substr($filename, -4), $search) !== false) return true; else return false; } ?> This functions look at the 4 last letters of the filename ignoring case, looking only the 3 last letters is not reliable at all: a file can have no extension... example, we check if the file is a ".rar" file: <?php $thisisararfile = checkext($_FILES["userfile"]["name"],".rar"); if ($thisisararfile) echo "OK, this is a .rar file!"; ?> Note that the "." must be included in the $search parameter. ---- Manual Page -- http://www.php.net/manual/en/function.move-uploaded-file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37328 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37328&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37328&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60222) next »