25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Accessing images<br />

Files in the public directory can be directly requested by appending their relative<br />

path to the site URL. For example, the default CSS file, public/css/app.css, can be<br />

requested at http://vuebnb.test/css/app.css.<br />

The advantage of using the public folder, <strong>and</strong> the reason we've put our images<br />

there, is to avoid having to create any logic for accessing them. A frontend app<br />

can then directly call the images in an img tag.<br />

You may think it's inefficient for our web server to serve images like<br />

this, <strong>and</strong> you'd be right. Later in the book, we'll serve the images<br />

from a CDN when in production mode.<br />

Let's try to open one of the mock listing images in our browser to test this thesis:<br />

http://vuebnb.test/images/1/Image_1.jpg:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!