Form Builder - File upload: Uploading files with file names over 159 characters doesn’t work
fodor11 opened this issue · comments
Package
filament/forms
Package Version
v3.x
Laravel Version
v10.x, v11.x
Livewire Version
v3.5.0
PHP Version
8.1.2
Problem description
If you try to upload a file with a name over 159 characters, the file doesn’t even get into the storage/app/livewire-tmp
directory, so obviously it doesn’t get saved into the file system either. This results in an array of errors – e.g. if you try to validate file size (->maxSize(512000)
) you get „Unable to retrieve the file_size for file at location: livewire-tmp/livewire-tmp.” error.
This file name is just long enough to produce the above described error:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
(160 characters including extension)
This file name on the other hand is just short enough to work perfectly:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
(159 characters including extension)
Expected behavior
I would expect it to work with the maximum length of file name permitted by the file system (usually 255 characters).
Steps to reproduce
- Get the reproduction repository working
- Log in
- Navigate to "File Uploads"
- Click "New file uploads"
- Upload a file with a long enough name (e.g.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
) - Click "Create"
- See the error
- (I beg you to fix it)
Reproduction repository
https://github.com/fodor11/laravel-filament-upload
Relevant log output
League\Flysystem\UnableToRetrieveMetadata
Unable to retrieve the file_size for file at location: livewire-tmp/livewire-tmp.
Donate 💰 to fund this issue
- You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
- 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
- Thank you in advance for helping us make maintenance sustainable!
This may be file system issue and not related to Filament
For example Windows has a MAX_PATH limit of ~256 characters
We are using Ubuntu 22.04, which means the file name length limit is 255 bytes, while the whole path can be a maximum of 4096 characters. If we copy the file to the file system manually, it works, so that can't be the problem
livewire issue livewire/livewire#3021
Thanks @wychoong