I am currently creating a PHP application that allows users to upload files. I am on the download page, but my verification system is not working. I use this system to check files as audio files.
// Set our file name and extension $fname = $_FILES['file']['name']; $extension = strtolower(substr($fname, strpos($fname, '.') + 1)); // Check file if ($extension == 'mp3' && $_FILES['file']['type'] == 'audio/mpeg') { //File is valid mp3 } else { //File is invalid }
Now this does not work, but it is strange when I echo from $_FILES['file']['type'] , it does not output the mime type for audio files. When I do this for any other type of file, it successfully drives it away.
It does not give the mime type only for audio files. I tried it with WAV and M4A files, and it does not return with any of them. Is this something with the file type, or do I need to edit the .htaccess file or the MIME.types file on my xampp server. Could there also be a better way to check downloaded files?
Also note that this is done on my xampp server and on a free server that I use for testing.
Thanks for the help.
source share