I am trying to parse a file thats been uploaded through a laravel nova application. I only want YML or XML files to come through and be parsed.
But to be able to distinct the uploaded files I want to check the mimetype so I can call the correct parser for either XML or YML.
However, when hovering over the uploadedFile (symphony) in the case of XML it tells me it is a "text/xml" mimetype. For YML it is a "application/octet-stream" mimetype.
Both of these files will return a "text/plain" mimetype when checked by ->getMimeType();
$mimeType = $file->getMimeType();
$finfo = new \finfo(FILEINFO_MIME_TYPE);
$test = $finfo->file($path);
Both $mimeType and $test return "text/plain".
Is there another way for me to determine the mimetype of XML/YML files? Expecting a mimetype along the lines of "text/xml", "application/xml", "text/YML", "application/yml"
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/35CB2xD
via IFTTT
Aucun commentaire:
Enregistrer un commentaire