I am creating a web app. when i am uploading an image its not able to fetch from the public folder and giving me back a 404 error.When i checked the error its not able to access the http://localhost/storage and through me an error. I have attached the error screenshot please check and help me. Check out the codes. Profile Model:
class Profile extends Model implements HasMedia
{
use HasMediaTrait;
public function user()
{
return $this->belongsTo(User::class);
}
public function image()
{
if($this->media->first())
{
return $this->media->first()->getFullUrl('thumb');
}
return null;
}
public function registerMediaConversions(?Media $media = null)
{
$this->addMediaConversion('thumb')
->width(100)
->height(100);
}
}
ProfileController
public function update(Request $request, Profile $profile)
{
if ($request->hasFile('image'))
{
$profile->clearMediaCollection('images');
$profile->addMediaFromRequest('image')
->toMediaCollection('images');
}
return redirect()->back();
}
Show.blade.php
@method('PATCH')
<div class="form-group row justify-content-center">
<div class='profile-avatar'>
<div onclick="document.getElementById('image').click()" class="profile-avatar-overlay">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 32 32">
<path d="M18 22.082v-1.649c2.203-1.241 4-4.337 4-7.432 0-4.971 0-9-6-9s-6 4.029-6 9c0 3.096 1.797 6.191 4 7.432v1.649c-6.784 0.555-12 3.888-12 7.918h28c0-4.030-5.216-7.364-12-7.918z"></path>
</svg>
</div>
<img src="" alt="" >
</div>
</div>
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2N1j4h1
via IFTTT
Aucun commentaire:
Enregistrer un commentaire