note 39182 added to function.move-uploaded-file
| From: | magnet_internet at hotmail dot com | Date: | Tue, 20 Jan 2004 01:17:24 +0000 |
| Subject: | note 39182 added to function.move-uploaded-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63854@lists.php.net to get a copy of this message | ||
Get your extension this way as well...this avoids problems if you have more than one '.'
in the filename. It will only match on the end of the string.
<?php
$FileName = "myfile.jpg";
preg_match("/\.(jpg|gif|png)$/i",$FileName,$Extension);
echo "The extension is " . $Extension[0];
?>
Returns "The extension is .jpg".
$Extension[1] would return "The extension is jpg", [1] being the memorized match from
what's in the parentheses in the regular expression.
Of course, modify the regular expression to match the extensions you're looking for. /i is
added for case insensitivity.
----
Manual Page -- http://www.php.net/manual/en/function.move-uploaded-file.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39182
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39182&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39182&report=yes
Search -- http://master.php.net/manage/user-notes.php