Skip to content

Commit

Permalink
fix: Handle the file removal event without manually deleting files (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
dasundev authored Apr 5, 2024
1 parent d92e7e9 commit f068541
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Http/Livewire/Dropzone.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ public function onFileAdded(array $file): void
public function onFileRemoved(string $tmpFilename): void
{
$this->files = array_filter($this->files, function ($file) use ($tmpFilename) {
$isNotTmpFilename = $file['tmpFilename'] !== $tmpFilename;

if (! $isNotTmpFilename) {
unlink($file['path']);
}

return $isNotTmpFilename;
// Remove the temporary file from the array only.
// No need to remove from the Livewire's temporary upload directory manually.
// Because, files older than 24 hours cleanup automatically by Livewire.
// For more details, refer to: https://livewire.laravel.com/docs/uploads#configuring-automatic-file-cleanup
return $file['tmpFilename'] !== $tmpFilename;
});
}

Expand Down

0 comments on commit f068541

Please sign in to comment.