Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Flex's avatar
Level 4

why this happening in my shared hosting server

working with Laravel 9 project and I have following public_path with image access in the blade file

<img src="{{ $message->embed(public_path('images/logo.png')) }}" alt="" style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block;">

this is working fine in my localhost and I have images folder in default public folder in the Laravel. but when I deploy My project to the shared hosting Hostgrator Laravel project public folder containts goes to the public_html folder. then I edit my App Service Provider.php and server.php as well for public_html any way my other images are working well in live server but above image path when i tryed to submit contact form data with email sending (site logo include with email attachment) uncounted following error message

Swift_IoException Unable to open file for reading [/home3/abc/abc/public_html/images/logo.png] 

how could I fix this problem?

0 likes
1 reply
LaryAI's avatar
Level 58

The issue is that the path to the image is incorrect on the shared hosting server. Instead of using public_path(), you should use asset() to generate the correct URL for the image.

Replace this line:

<img src="{{ $message->embed(public_path('images/logo.png')) }}" alt="" style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block;">

With this line:

<img src="{{ $message->embed(asset('images/logo.png')) }}" alt="" style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block;">

This should generate the correct URL for the image on the shared hosting server.

Please or to participate in this conversation.