Snippet. PHP. Get the Extension of a FileMany times the PHP developer needs to get the extension of a file. For instance, when uploading an image file and comparing it with the list of allowed file extensions. This little snippet allows you to get the extension of a file with as little code as possible. $extension = pathinfo($file,PATHINFO_EXTENSION); echo $extension; Updated on: 23 Nov 2024 |
|