I want to upload a .eps file. to do this I have a form to upload multiple images and this all works fine.
When I upload a .eps. file, the Validator class fails. This is my code for the validator:
// $file is an instance of UploadedFile
$validator = \Validator::make( [
'file' => $file
], [
'file' => 'required|mimes:jpg,jpeg,png,tiff,psd,ai,eps,pdf'
] );
\dd($validator->fails());
if ($validator->fails() ){
...
}
This is because the mimetype (according to \Symfony\Component\HttpFoundation\File\File::getMimeType is application/octet-stream.
When I dd $file, this is the result:
UploadedFile {#410 ▼
-test: false
-originalName: "2365 MD8300PC03.eps"
-mimeType: "application/postscript"
-size: 310578
-error: 0
#hashName: null
path: "/private/var/tmp"
filename: "phpI2fYV6"
basename: "phpI2fYV6"
pathname: "/private/var/tmp/phpI2fYV6"
extension: ""
realPath: "/private/var/tmp/phpI2fYV6"
aTime: 2017-07-11 12:40:54
mTime: 2017-07-11 12:40:52
cTime: 2017-07-11 12:40:52
inode: 21493674
size: 310578
perms: 0100600
owner: 504
group: 0
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}
When I dd $file->getClientMimeType, the result is application/postscript, which is the correct mimetype.
The only option I can think of at the moment is to override the File class so I can check the mimetype before it's returned by the method.