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 livewire-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.
No description
No description
2 Replies
K R A T O S
K R A T O SOP11mo ago
[2024-02-25 21:28:39] production.ERROR: Call to undefined function Livewire\Features\SupportFileUploads\tmpfile() {"userId":1,"exception":"[object] (Error(code: 0): Call to undefined function Livewire\\Features\\SupportFileUploads\\tmpfile() at /home/r29DzYpOj3vU0dUw/PaulBridgesPlastering_Website/public_html/vendor/livewire/livewire/src/Features/SupportFileUploads/TemporaryUploadedFile.php:23)
[stacktrace]
[2024-02-25 21:28:39] production.ERROR: Call to undefined function Livewire\Features\SupportFileUploads\tmpfile() {"userId":1,"exception":"[object] (Error(code: 0): Call to undefined function Livewire\\Features\\SupportFileUploads\\tmpfile() at /home/r29DzYpOj3vU0dUw/PaulBridgesPlastering_Website/public_html/vendor/livewire/livewire/src/Features/SupportFileUploads/TemporaryUploadedFile.php:23)
[stacktrace]
This is my error log frmo laravel.log
Igor
Igor11mo ago
It's possible that there is a permission issue in the folders. You could try this solution to see if it resolves the problem. https://stackoverflow.com/questions/30639174/how-to-set-up-file-permissions-for-laravel
Stack Overflow
How to set up file permissions for Laravel?
I'm using Apache Web Server that has the owner set to _www:_www. I never know what is the best practice with file permissions, for example when I create new Laravel 5 project. Laravel 5 requires /

Did you find this page helpful?