jenisara's avatar

Laravel validation for kml file

Hi,I am working on a form where file upload must be only .kml or .shp file , i gave validation as

'aoi' => 'required|mimes:kml,shp',

but still showing error "The aoi must be a file of type: kml." Please help.

0 likes
2 replies
D9705996's avatar
D9705996
Best Answer
Level 51

The documentation for mimes states

Even though you only need to specify the extensions, this rule actually validates against the MIME type of the file by reading the file's contents and guessing its MIME type.

Therefore you file needs to have a valid mime type. If you only care about the extension you could use a regular expression e.g. below is ends with kml

'aoi' => 'regex:/kml$/i'

Please or to participate in this conversation.