Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

iamlux20's avatar

Preventing "Unable to retrieve the file_size for file at location livewire-tmp/imagename.jpg"

Hello, this has been a problem of mine for the past 3 months. If some field in a validation test case fails, the upload file does this even though the preview exists. Is there a way to prevent this?

I am using public file storage and storage:link is existing. I have also tried unsetting/resetting the input file but still fails

FileUpload::make('supporting_documents')
    ->label('Supporting Documents')
    ->multiple()
    ->preserveFilenames()
    ->required()
    ->openable()
    ->downloadable()
    ->moveFiles()
    ->previewable(true)
    ->maxSize(10000)
    ->helperText('Accepts .pdf or image files up to 10MB only.')
    ->acceptedFileTypes(['application/pdf', 'image/*'])
0 likes
9 replies
Nakov's avatar

@iamlux20 it will help a lot if you share some code on what you are trying to do.

Nakov's avatar

@iamlux20 just out of curiosity, can you comment this line: ->preserveFilenames() and check if you'll get the error without that line?

iamlux20's avatar

@Nakov Unable to retrieve the file_size for file at location: livewire-tmp/V5oPAIUnBTWr5lkCrW5ElNHFVq9O5t-metaNDQ1ZjU2NWYtYjIwNi00NzRmLThkY2EtMzY3MmY4MjBlMGQzLmpwZWc=-.jpg.

When an error or validation is encountered during submission, the file gets deleted. That's why it triggers a file_size error

Nakov's avatar

@iamlux20 I get it, but in order to debug which of the options causes the error, I would add them one by one.. probably start with a simple setup like this:

FileUpload::make('supporting_documents')
    ->label('Supporting Documents')
    ->multiple()
    //->preserveFilenames()
    ->required()
    //->openable()
    //->downloadable()
    ->moveFiles()
    //->previewable(true)
    ->maxSize(10000)
    ->helperText('Accepts .pdf or image files up to 10MB only.')
    ->acceptedFileTypes(['application/pdf', 'image/*'])

and see if the error appears even on the simplest one and uncomment each option as you try..

iamlux20's avatar

@Nakov same, I've commented the required() and moveFiles() along with it

Nakov's avatar

@iamlux20 thank it is most probably permission issues on your folder..

STOG's avatar

I know this was months ago, but I stumbled across this thread while facing a similar issue with my Filament V3 project. In my case, the problem was a truncation issue in the database. I had my columns for storing the file path defined as VARCHAR, which has a maximum length limit. When the file path exceeded that limit, issues like this occurred.

I changed the column type to LONGTEXT to fix it, and everything started working as expected. Here’s an example migration to help:

php artisan make:migration update_file_path_column_to_longtext --table=your_table_name
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateFilePathColumnToLongText extends Migration
{
    public function up()
    {
        Schema::table('your_table_name', function (Blueprint $table) {
            $table->longText('supporting_documents')->change();
        });
    }

    public function down()
    {
        Schema::table('your_table_name', function (Blueprint $table) {
            $table->string('supporting_documents', 255)->change(); 
        });
    }
}

Please or to participate in this conversation.