Level 75
This section explains: https://laravel.com/docs/8.x/filesystem#the-public-disk
To display I use the asset helper:
<img src="{{ asset('assets/upload/imgdogs') . '/' . $row->dogpic }}" alt="" class="image">
Change to your folder.
2 likes
I recently began using livewire and can't seem to get it to save to the public_path /upload directory so I can formulate an link to display and image.
DetailImageUpload.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use Livewire\WithFileUploads;
use App\Models\estimate\Detail;
class DetailImageUpload extends Component
{
use WithFileUploads;
public $image;
public $detail_id;
public function render()
{
return view('livewire.detail-image-upload');
}
public function save()
{
$this->validate([
'image' => 'image|max:1024', // 1MB Max
]);
$image = $this->image->storeAs('details', $this->detail_id);
$data['image'] = $image;
$detail = Detail::find($this->detail_id);
$detail->update($data);
}
}
I tried changing the storeAs to '/public/upload' but it ends up only creating that structure under storage.
This section explains: https://laravel.com/docs/8.x/filesystem#the-public-disk
To display I use the asset helper:
<img src="{{ asset('assets/upload/imgdogs') . '/' . $row->dogpic }}" alt="" class="image">
Change to your folder.
Please or to participate in this conversation.