@viernes You understand the problem right? If you mention localhost in your
src= tags then when you want to move it to your hosting, then all your references will be broken.
The correct function, as mentioned here is asset, eg
For this to work, you MUST have the public folder as the Document Root , ie, the root of your website
/ should be the index.php in your public folder.
I have never seen so many folks having trouble simply displaying an image.
Shared or dev folder structure:
DO may be different, but they actually have tutorials.
And go to the docs and find the asset helper.
<img src="<?php echo asset('assets/upload/imgdogs') . '/' . $row->dogpic; ?>" alt="" class="image">
I used php echo, just convert to blade, as don't use blade.
Folks new to laravel, I promise if you would goto them docs and work Taylor's examples you would really learn this stuff.
And Jeffrey has free videos on many of the basics.
The main thing is to have APP_URL set correctly in the .env file, and then use the asset helpers. APP_URL should bring you to the homepage of the app. So you if you need to access
http://localhost/some/project/public to get to your homepage, that's what it should be set for. Then when you change hosts, all you need to do is change APP_URL to the new domain name and everything will still work. The best thing though is to set up a actual host on your dev server so you can just access it with
http://projectname.test so you don't have to have the path of the site in the url.
The asset helpers use the APP_URL to help generate the full url.
You don't even have to use helper.
something Simple make a big impact for the new folks to laravel.
I agree but it still just an image SRC you could do it the same way you did in PHP prior to going to laravel. Even your basic HTML studies it's the same way. Taylor just threw in a helper is all, like yii and cakephp they have helpers.
Echo out what the helper does and you will see it's as though you typed it all out anyway.
In fact I went over a year before I stumbled across the helper, and was just doing it the normal way anyway. I definitely like some of the helpers Taylor put in.