Level 54
Sep 22, 2020
4
Level 14
Help with mime type validation for file upload
Hi
I'm trying to add mime type validation to a file upload so that it will only accept dotx (Word template files)
The validation code looks like this
$req->validate([
'file' => 'required|mimetypes:application/vnd.openxmlformats-officedocument.wordprocessingml.template|mimes:dotx|max:2048'
]);
Validation fails
the 'dump' of the file in the request looks like this:
"_token" => "k1lVpV6EOUfbmHPPIdDpQJy1rIrOSgJ3Gxj7FkWZ"
"submit" => null
"file" => Illuminate\Http\UploadedFile {#419 ▼
-test: false
-originalName: "esd_test_1.dotx"
-mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.template"
-error: 0
#hashName: null
path: "/tmp"
filename: "phpyUp9CW"
basename: "phpyUp9CW"
pathname: "/tmp/phpyUp9CW"
extension: ""
realPath: "/tmp/phpyUp9CW"
aTime: 2020-09-22 08:42:08
mTime: 2020-09-22 08:42:08
cTime: 2020-09-22 08:42:08
inode: 1048607
size: 12006
perms: 0100600
owner: 1000
group: 1000
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}
what did I miss?
Please or to participate in this conversation.