© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
12 replies
Shaung Bhone

Pesting form builder with upload file

I am trying to test upload the file in my order. That gives me an error
foreach() argument must be of type array|object, string given.
foreach() argument must be of type array|object, string given.
Here is my code.
Forms\Components\FileUpload::make('screenshot')
    ->required()
    ->label(__('Screenshot'))
    ->directory('transaction-images')
    ->columnSpanFull(),
Forms\Components\FileUpload::make('screenshot')
    ->required()
    ->label(__('Screenshot'))
    ->directory('transaction-images')
    ->columnSpanFull(),

test('user can order the product', function () {
    $this->actingAs(User::factory()->create());

    $file = Illuminate\Http\UploadedFile::fake()->create('screenshot.jpg');

    livewire('order.create')
        ->fillForm([
            'url' => fake()->url(),
            'screenshot' => $file->name,
        ]);
});
test('user can order the product', function () {
    $this->actingAs(User::factory()->create());

    $file = Illuminate\Http\UploadedFile::fake()->create('screenshot.jpg');

    livewire('order.create')
        ->fillForm([
            'url' => fake()->url(),
            'screenshot' => $file->name,
        ]);
});
Screenshot_2024-06-07_220104.png
Solution
It's working now. That does not belong with version breaks
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Form builder - File fields?
FilamentFFilament / ❓┊help
3y ago
Form Builder and file uploads
FilamentFFilament / ❓┊help
3y ago
File Upload Form In Server
FilamentFFilament / ❓┊help
13mo ago
form builder
FilamentFFilament / ❓┊help
2y ago