ollie_123's avatar

Validation Mimes:... Issue

Afternoon All

I'm having an issue with uploading a few file types even though i have declared them as ok in the validation:-

$this->validate([
	....
    'file'      => 'required|file|mimes:slave,bin,fpf,ori,dat,org,bak,|max:5000',
]);

But when i go to upload a .bak or .slave file it gives me a validation error of file type must be as per the list but the file type is as per the list.

Is there a better way of validating the file types with custom file types?

Any advice would be much appreciated.

Thanks in advance.

0 likes
5 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Check the mimetype locally to see what it actually is

file --mime-type -b file.slave
1 like
ollie_123's avatar

Legend, thanks @Sinnbeck, never used that before but worked a treat. Turns out it was a application/zip

Thanks again. :)

ollie_123's avatar

Hey @sinnbeck, sorry to resurrect this one, i seem to be having a weird issue where in the validation i allow for ```slave, zip`,bin`` etc but when i upload a .slave file its converting it to .zip.

The strange thing is i'm storing it with the original extension...

$fileName = $this->file->getClientOriginalName() . '.' . $this->file->getClientOriginalExtension();

How do i keep the file in its original structure without Laravel converting it to zip? Any advice would be greatly appreciated :).

Thank you in advance.

Sinnbeck's avatar

@ollie_123 not sure what you mean? It appends zip to the filename or it actually changes the content of the file?

Consider making a new thread with this new issue so others can also help trying to solve it

Please or to participate in this conversation.