Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Avatar Image in Laravel


Hi. I have fresh installed Metronic Laravel. I tried to edit the avatar. The link is saved to the db, but the avatar not shown neither in the profile page or the navbar.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (23)


Hi Reza,

Could you please verify if the image is being uploaded properly? Please check it in the Laravel storage folder.


storage/app/public


Thanks



Yes I have the images inside

storage/app/public/images



Hi,

Could you please check the browser console log if there is any error? Could you please send the screenshot?

Thanks



I got an upload success response. And for the console log, I only got error for the logo

Failed to load resource: the server responded with a status of 403 (Forbidden)



We have to check what error cause it. Maybe you can try to check on this network log. If there is an error in the response, we can see it after submitting it.




Thanks



Got this message in both preview and response
"Failed to load response data: No content available because this request was redirected"



<img>https://ibb.co/f95dWnf



How can I upload a captured image here so it will be easier for you to see it



You can use embed code HTML from here.



Upload succeed and image saved to the storage>images folder. But still not shown. Are there any other Metronic Laravel settings or Laravel classes I missed?



Any new updates?



I also tried to use the absolute image path to replace the img src link but not working

<img src="%7B%7B%20auth()->user()->avatar_url%20%7D%7D%22%20alt=%22image" class="w-100" alt="">



Hi Reza,

How about the folder permission? Have you tried to check on it? Could you please try to set some read-write permission for the storage folder? Here is some guidance for the Laravel folders.

https://stackoverflow.com/a/66109044

Thanks



Hi Faizal,

The app is still in local dev. And yes, the storage permission to read-write



I am using Laragon, if it helps for troubleshooting



Hi Reza,

Sorry for the delay. Have you found the solution to this issue?

Could you please check in the HTML inspector and check the image URL?
<br /><a target='_blank' href='https://imgbb.com/'>ismail image</a><br />

Thanks



I did have found the solution. I think it's related to the storage link command. Maybe you should check the default Metronic Laravel files for the avatar file routing. It will not work after running the storage link command since it will require the

asset
. Or, perhaps it's just me.
Thank you for the excellent support.



Sorry for the inconvenience. I hope this will help other users as well. We already put the step (no 14) in the documentation.

https://preview.keenthemes.com/metronic8/laravel/documentation/getting-started/build

Thanks



Hi Reza,
I have the same problem.
Please, how to solve the problem?



Remove the access to storage in public folder

Then "php artisan storage:link"



I tried all the solutions but still facing the same issue...The image is being uploaded to 'public/app/avatars'.

This is the code in the settings controller:


$file = null;
if (request()->hasFile($key)) {
// $file = Storage::disk("public")->putFile($folder, request()->file($key), "public");
if( request()->hasfile($key) )
{
$file = request()->file($key);
$extension = $file->getClientOriginalExtension();
$filename = $key . auth()->user()->name . "." . $extension;
$file->move("app/avatars/", $filename);
$key = $filename;
}
return $file;
}


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(