20 lines
388 B
PHP
20 lines
388 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Services;
|
||
|
|
|
||
|
|
use Illuminate\Http\UploadedFile;
|
||
|
|
|
||
|
|
class AutoCleanupUploadedFile extends UploadedFile
|
||
|
|
{
|
||
|
|
public function __destruct()
|
||
|
|
{
|
||
|
|
$path = $this->getPathname();
|
||
|
|
if ($path !== '' && file_exists($path)) {
|
||
|
|
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
||
|
|
@unlink($path);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|