Using Global var $_FILES you can find out all information about the original file
for example name, size
Look to this Example
How to get uploaded file extension in PHP
Using Global var $_FILES you can find out all information about the original file
for example name, size
Look to this Example
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="myUploadFile">
<input type="submit">
</form>
<?php
if(isset($_FILES["myUploadFile"])){
$GetName = $_FILES["myUploadFile"]["name"];
$GetExtension = explode(".", $GetName);
$GetExtension = strtolower(end($GetExtension));
echo $GetExtension ;
}
?>
Explanation of the previous code
you have single page contains the form and PHP code
first check if $_FILES["myUploadFile"] exist
then i will get the uploaded file full name throw $_FILES["myUploadFile"]["name"]
after that, i will use explode() function to make an array
and i will get the last item using end() function