Laravel-文件mimetype验证对于某些具有相同mime的文件失败

时间:2018-07-19 20:29:20

标签: php laravel laravel-5.6 php-7.2

我有两个mp3文件,比如file1.mp3file2.mp3。当我上载file1时,它已成功上载,但对于file2而言却不一样,因为错误的mimetype验证失败。验证输入的字符串是:

$rules['arquivos.*'] = 'required|mimetypes:image/jpeg,image/png,image/gif,video/webm,video/mp4,audio/mpeg';

该表单的html代码为:

{!! Form::open(['route' => 'posts.store', 'enctype' => 'multipart/form-data', 'class'=>'form-post']) !!}
<input class="novo-post-form-item form-post-file-input" name="arquivos[]" type="file" onchange="addNovoInputFile(this, {{ $configuracaos->num_max_arq_post }})">
// rest of the form

如果我同时运行filemimetype命令,它将返回完全相同的东西:

fabio@fabiopc:~$ mimetype ~/Music/file1.mp3 
/home/fabio/Music/file1.mp3: audio/mpeg

fabio@fabiopc:~$ mimetype ~/Music/file2.mp3 
/home/fabio/Music/file2.mp3: audio/mpeg

fabio@fabiopc:~$ file ~/Music/file1.mp3 
/home/fabio/Music/file1.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1,  64 kbps, 44.1 kHz, Stereo

fabio@fabiopc:~$ file ~/Music/file2.mp3 
/home/fabio/Music/file2.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1,  64 kbps, 44.1 kHz, Stereo

所以有人知道这可能是什么错误吗?还是laravel验证部分内部存在错误?

编辑:我还发现某些图像文件也正在发生这种情况。

0 个答案:

没有答案