Reputation: 2223
Laravel 7 on PHP 7 is detecting incorrect MIME type of application/octet-stream
for .ogg extension.
Here is the applicable file request dump:
Illuminate\Http\UploadedFile {#1274 ▼
-test: false
-originalName: "03 - See You Tonite.ogg"
-mimeType: "application/octet-stream"
Anybody know of a workaround for this?
Upvotes: 1
Views: 1536
Reputation: 4398
Check your mime type file first:
return $request->file('field_name')->getMimeType();
Now you can add the following code in the boot method in AppServiceProvider:
public function boot()
{
Validator::extend('ogg_extension', function($attribute, $value, $parameters, $validator) {
if(!empty($value->getClientOriginalExtension()) && ($value->getClientOriginalExtension() == 'ogg')){
return true;
}else{
return false;
}
});
}
Upvotes: 1