Uploading font files .ttf and .otf
Has anybody been able to upload .ttf or .otf font files using FileUpload?
I have even tried the following
->acceptedFileTypes(['application/x-font-ttf', 'font/ttf', '.ttf'])
but I constantly get "File of Invalid Type".
Not doing anything crazy with the component and images etc work just fine.
Forms\Components\FileUpload::make('header_font_file')->directory('fonts')->visibility('public')->acceptedFileTypes(['application/x-font-ttf', 'font/ttf', '.ttf'])
28 Replies
I should note that if I do not set any acceptedFileTypes that the file looks like it passes with FileUpload but it doesn't go into temporary storage and when I save the resource, it doesn't get saved to main directory either.
Run your file through an actual mimetype check to make sure it is one of those file types.
Hey @awcodes, I checked this to be
application/x-font-ttf
but I have tried with many other files of the same type too. it is also the same with .otf
Nobody else experienced this at all? I’m going to assume it’s a Filament bug and report it 👍As long as the mine type is correct I don’t see why filepond or filament would care.
Honestly not sure what the problem would be.
It is a strange one for sure. I don't have issues with any other file type except fonts.
Are you getting a validation error or a server error?
Nope. It immediately errors out as File of Invalid Type in FileUpload and then if I remove all acceptedFileTypes it allows (appears to) the upload but nothing gets added to temporary and upon save, the FileUpload is empty, nothing gets passed to the database and nothing gets uploaded.
Everything is standard.
Forms\Components\FileUpload::make('header_font_file')->directory('fonts')->visibility('public')->acceptedFileTypes(['application/x-font-ttf', 'font/ttf', '.ttf'])
If I change the filetype to anything else, it all just worksCan you try removing the .ttf since that isn’t an actual mime type?
I have tried all combinations of them individually and all together but I will try this again now.
Also can you send a screenshot of the error. That might help me to understand where the issue is occurring.
Sure, here you go
Here is one with just the ttf mime types
The file types are being passed directly to filepond, so could be a bug in fileponds file type plugin.
I’m wondering too if your server doesn’t recognize the mine type.
And therefore can’t properly determine it from the tmp uploaded file.
Well, this is local right now running on Herd. I could deploy tomorrow to my actual server and test there but not sure that that will make a difference in all honesty. Did you attempt to replicate the error? Not expecting you to try btw, I appreciate all of your help so far but was just wondering if you had tried on your side.
Hmm, I would think heard would be ok.
I haven’t tried. Busy with work and always from the computer right now.
Yep, me too. I think it's just a bug, honestly but you're probably right that it is on Filepond side and not Filament.
Not seeing any issues on fileponds GitHub about it.
Honestly, just rubber ducking is a big help mate. Don't expect you to try.
Could be something in livewire too and it’s TemporaryUploadedFile class.
Thinking of accepting a .zip instead and unzipping locally 😂
The fact that it’s not detecting it as an octet-stream is odd too.
Yep, as the main fallback, I would have assumed that it would have taken that
Zip would work, but you’d have to manage possible multiple files in it.
Yeah, it's a closed system so I "could" tell the users to do so but users do user things...
Not the end of the world. Might even be a benefit since they could upload ttf, woff, etc all in one go.
Yes they do. 😅😂
Thanks for all of your help mate. Appreciate what you do for us all as a community too. Back to the drawing board for now...
Keep me in the loop.
I’ll try it when I get a free moment, just for a sanity check and let you know.
Appreciate you x