© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
benjji92

FileUpload doesnt work properly

I have an action that uploads an excel file and run a script with the data in it, then deletes the uploaded file since its no longer needed.

->actions([
                Tables\Actions\Action::make('Run')
                    ->label('Run script')
                    ->color('danger')
                    ->size('lg')
                    ->icon('heroicon-o-play')
                    ->requiresConfirmation()
                    ->form([
                FileUpload::make('excel')
                    ->label('Excel')
                    ->acceptedFileTypes(['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])
                    ->preserveFilenames(),
                ])
                ->action(function ($data) {
                    $path = $data['excel'];
                    $deleteScript = new Script();
                    $deleteScript->delete($path);
                    Storage::delete($path);
                })
->actions([
                Tables\Actions\Action::make('Run')
                    ->label('Run script')
                    ->color('danger')
                    ->size('lg')
                    ->icon('heroicon-o-play')
                    ->requiresConfirmation()
                    ->form([
                FileUpload::make('excel')
                    ->label('Excel')
                    ->acceptedFileTypes(['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])
                    ->preserveFilenames(),
                ])
                ->action(function ($data) {
                    $path = $data['excel'];
                    $deleteScript = new Script();
                    $deleteScript->delete($path);
                    Storage::delete($path);
                })



class DeleteScript
{
    public function delete($path)
    {
        $data = Excel::toArray([], $path); 
        foreach ($data as $row) {
            $videoCode = trim(implode('', $row[0]));
            if(empty($videoCode)){
                continue;
            }
            //Log::info("videocode: $videoCode");
            $video = Videos::where('code', $videoCode)->delete();
        }
    }
}
class DeleteScript
{
    public function delete($path)
    {
        $data = Excel::toArray([], $path); 
        foreach ($data as $row) {
            $videoCode = trim(implode('', $row[0]));
            if(empty($videoCode)){
                continue;
            }
            //Log::info("videocode: $videoCode");
            $video = Videos::where('code', $videoCode)->delete();
        }
    }
}


For example: I upload a delete.xlsx file, but I get the following error:

Could not find zip member zip://C:\laragon\www\fanny\storage\framework\cache\laravel-excel\laravel-excel-yBCw78HjXxAlznjDQ609T9mkdHe52RYz.xlsx#_rels/.rels
Could not find zip member zip://C:\laragon\www\fanny\storage\framework\cache\laravel-excel\laravel-excel-yBCw78HjXxAlznjDQ609T9mkdHe52RYz.xlsx#_rels/.rels


I found out that if I place this delete.xlsx in the \storage\app folder, the code runs without error, succesfully deleting the data given in the excel file.
How is this related? The uploaded excel file goes to the \storage\app\public folder.
What goes wrong here?
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

FileUpload doesnt save to public
FilamentFFilament / ❓┊help
3y ago
Uploading doesnt work
FilamentFFilament / ❓┊help
2mo ago
Copyable doesnt work
FilamentFFilament / ❓┊help
3y ago
TagsInput afterStateUpdated() doesnt work
FilamentFFilament / ❓┊help
3y ago