Uploading images in Production
Hi.
I am trying to upload images to my app in production. I can see the images being stored in the
Code:
Any help appreciated.
Thanks.
I am trying to upload images to my app in production. I can see the images being stored in the
livewire-tmplivewire-tmp folder but when Its trying to save it to the public disk, It throws me a 500 error. Below is my code and the response and errors.Code:
class ListGalleryImages extends ListRecords
{
protected static string $resource = GalleryImageResource::class;
protected function getHeaderActions(): array
{
return [
Actions\Action::make('upload')
->label('Upload Images')
->form([
Forms\Components\FileUpload::make('images')
->disk('public')
->directory('gallery')
->multiple()
->getUploadedFileNameForStorageUsing(
fn(TemporaryUploadedFile $file): string => Str::uuid()->toString() . '.' . $file->getClientOriginalExtension(),
)
->storeFileNamesIn('file_original_name')
])
->closeModalByClickingAway(false)
->action(function (array $data) {
$images = $data['images'];
$originalNames = $data['file_original_name'];
foreach ($images as $image) {
GalleryImage::query()->create([
'file_path' => $image,
'file_original_name' => $originalNames[$image],
'file_name' => explode('/', $image)[1],
]);
}
})
];
}
}class ListGalleryImages extends ListRecords
{
protected static string $resource = GalleryImageResource::class;
protected function getHeaderActions(): array
{
return [
Actions\Action::make('upload')
->label('Upload Images')
->form([
Forms\Components\FileUpload::make('images')
->disk('public')
->directory('gallery')
->multiple()
->getUploadedFileNameForStorageUsing(
fn(TemporaryUploadedFile $file): string => Str::uuid()->toString() . '.' . $file->getClientOriginalExtension(),
)
->storeFileNamesIn('file_original_name')
])
->closeModalByClickingAway(false)
->action(function (array $data) {
$images = $data['images'];
$originalNames = $data['file_original_name'];
foreach ($images as $image) {
GalleryImage::query()->create([
'file_path' => $image,
'file_original_name' => $originalNames[$image],
'file_name' => explode('/', $image)[1],
]);
}
})
];
}
}Any help appreciated.
Thanks.

