I had this
$file = array('file' => Input::file('file'));
and
dd($file);
return
How do I access file mimeType via the Laravel way ?
I had this
$file = array('file' => Input::file('file'));
and
dd($file);
return
How do I access file mimeType via the Laravel way ?
You can the mime type of the file retrieve it like this:
$file['file']->getMimeType();
You may use one of this functions:
$file['file']->getClientMimeType();
The client mime type is extracted from the request from which the file was uploaded, so it should not be considered as a safe value. For a trusted mime type, use
getMimeType()
instead (which guesses the mime type based on the file content).
$file['file']->getMimeType();
The mime type is guessed using a
MimeTypeGuesserInterface
instance, which usesfinfo_file()
then the "file" system binary, depending on which of those are available.