mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge pull request #544 from chiiya/main
Allow specifying file name for uploaded files
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Filament\Forms\Concerns;
|
||||
|
||||
use Filament\Forms\Components\Field;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@@ -83,8 +84,7 @@ trait CanUploadFiles
|
||||
continue;
|
||||
}
|
||||
|
||||
$storeMethod = $field->getVisibility() === 'public' ? 'storePublicly' : 'store';
|
||||
$path = $temporaryUploadedFile->{$storeMethod}($field->getDirectory(), $field->getDiskName());
|
||||
$path = $this->storeFile($temporaryUploadedFile, $field);
|
||||
$this->syncInput($field->getName(), $path, false);
|
||||
}
|
||||
|
||||
@@ -134,4 +134,11 @@ trait CanUploadFiles
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
|
||||
protected function storeFile(UploadedFile $file, FileUpload $field)
|
||||
{
|
||||
$storeMethod = $field->getVisibility() === 'public' ? 'storePublicly' : 'store';
|
||||
|
||||
return $file->{$storeMethod}($field->getDirectory(), $field->getDiskName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user