Yii2/Kartik V FileInput MP3 fails validation in Chrome/Chromium

Web Tips Q & ACategory: Krajee Yii2 ExtensionsYii2/Kartik V FileInput MP3 fails validation in Chrome/Chromium
joncojonathan asked 5 months ago

Hello,
I’m using boostrap-fileinput with Yii2 and have a form where MP3 upload should be permitted.  I’ve added the file upload field like this:
 

<?php
echo $form->field($model, 'file_name')->widget(FileInput::classname(), [
'pluginOptions' => [
'allowedFileExtensions' => ['jpg', 'gif', 'png', 'pdf', 'mp3', 'mp4', 'mov'],
'allowedFileTypes' => ['image', 'text', 'audio', 'video', 'object']
]
]);
?>

This works fine in Firefox, however, in Google Chrome, Google Chrome Mobile and Chromium the user receives an error on the validation:

Only files with these MIME types are allowed: image/jpeg, image/gif, image/png, application/pdf, audio/mpeg.

I can’t work out why I’m seeing this behaviour, although research has shown Chrome uses audio/mp3 as the mime type.  I tried adding that to allowedFileTypes but to no avail.
Any assistance would be appreciated,
 
Jonathan

Login or register to contribute or comment.

Login   Register