This post will help you to get file type of any uploaded file.
1 2 3 4 5 6 |
<?php $ftype = $_FILES['userFiles']['type']; // This will get the whole file type like image/jpg,audio/mp3 etc // Let's get the exact file type. Follow the below code $file_ext=@split ("\/", $ftype); $file_ext=$file_ext[0]; // This variable will get the exact file type like image, audio etc ?> |
That’s it. Try this code and you will get the exact file type.