0

I have this code to upload audio files. It works fine in chrome and opera, but when I try to upload an mp3 file in ie or the Windows 10, Edge, it won't work. It will work in those browsers for wav filetype. Here is the pernenant part of the code:

 protected $permittedTypes = array(
        'audio/mp3',
        'audio/wav',



);
    protected function checkType($file) 
{
    if (in_array($file['type'], $this->permittedTypes)) {
        return true;
    } else {
        $this->messages[] =  'is not permitted type of file';
        return false;
    }
}

I get the message 'is not permitted type of file' only if I try to upload an mp3 file in a non webkit browser. Otherwise, it works fine.

Any help will be greatly appreciated.

I just tried added audio/mpeg to the $protectedTypes array and now it works.

  • So called MIME-detection is entirely based on known file-extensions. For example, if a user will rename `evil.php` to `evil.mp3` and upload it, your validation is by-passed. Be aware of this. – Yang Oct 11 '15 at 11:24
  • For IE, you could, maybe, try with audio/mpeg: http://stackoverflow.com/questions/10688588/which-mime-type-should-i-use-for-mp3 – sinisake Oct 11 '15 at 11:37

0 Answers0