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); }) 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 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?
1 Reply
benjji92
benjji92OP2y ago
Also the other problem I noticed is that it doesnt delete the uploaded file itself from the \storage\app\public folder, but the file I copied there manually to the \storage\app folder. problem solved with $path = 'public/' . $data['excel'];
Want results from more Discord servers?
Add your server