filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.

Home Page:https://filamentphp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Get the reproduction repository working
  2. Log in
  3. Navigate to "File Uploads"
  4. Click "New file uploads"
  5. Upload a file with a long enough name (e.g. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf)
  6. Click "Create"
  7. See the error
  8. (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!
Fund with Polar

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