note 43962 deleted from function.move-uploaded-file by aidan
| From: | aidan@php.net | Date: | Sat, 10 Jul 2004 13:22:10 +0000 |
| Subject: | note 43962 deleted from function.move-uploaded-file by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72988@lists.php.net to get a copy of this message | ||
Note Submitter: Stephen Williams
----
You can find the file extension using this function:
$VAR_file = "test.jpg";
$VAR_extension = get_file_extension($VAR_file); //returns jpg
function get_file_extension($VAR_file_name) {
$VAR_pieces = explode(".", $VAR_file_name);
$VAR_piece_count = count($VAR_pieces) - 1;
$VAR_this_extension = $VAR_pieces[$VAR_piece_count];
return $VAR_this_extension;
}
This works on all files, even ones with multiple .'s in them.
Example
test.jpg will return "jpg"
test.test.test.test.jpg will return "jpg"