如果上传的文件是csv文件,我在symfony中创建一个约束。
$fileContraints = new File(array('maxSize' => '2M', 'mimeTypes' => array('text/csv', 'text/plain')));
如果我上传从excel导出的csv文件,则验证失败。我查看发布的mimetype
object(Symfony\Component\HttpFoundation\File\UploadedFile)[12]
private 'test' => boolean false
private 'originalName' => string 'Export-20141027.csv' (length=19)
private 'mimeType' => string 'application/vnd.ms-excel' (length=24)
private 'size' => int 120634
private 'error' => int 0
然后我检查服务器上的文件mimetype
file -b --mime <filename>
并获得ouptut
text/plain; charset=utf-8
来自php和控制台的输出文件类型不同。我如何处理这个以获得我发布的文件的正确mimetype验证?