<img src="{{ asset('/storage/'.$school->logo_path) }}" alt="">
Storage::url() not working
I used Storage::url() to get the path to the image. I have logo_path stored in the database and I wanted to print the logo. The funniest part is Storage::url($school->logo_path) won't display the image which is printed in the src attribute of an img tag but if I dd(Storage::get($school->logo_path) I get the binary data of an image, even the code below works completely fine.
if (Storage::exists($school->logo_path)) {
Storage::delete($school->logo_path);
}
I created symlink with php artisan command, I tried url($school->logo_path), asset($school->logo_path) no change at all.
<img src="{{ $school->logo_path ? Storage::url($school->logo_path) : url('/img/default-school.jpg') }}" alt="{{ $school->name . ' logo' }}"> // not displaying the image
Anyone with help, please?
Here is the code to store the path in the DB
if ($request->hasFile('logo_path')) {
if ($school && Storage::exists($school->logo_path)) {
Storage::delete($school->logo_path);
}
$extension = $request->logo_path->extension();
$fileName = implode('_', explode(' ', $request->name));
$fileName = $fileName . "_logo." . $extension;
$path = $request->logo_path->storeAs('public/school-logos', $fileName);
return $path;
}
I am on Windows 10 Machine, PHP version 7.4, and Laravel Ver 8.12
Unless the symlink didn't work, because asset helper is working for me.
Please or to participate in this conversation.