laravelpublicshared-directory

Access image folder from Laravel Project A to Laravel B, C, D etc


Let's say I have main project Laravel A, which stores photos of employees. I need the rest of the Laravel projects B, C and so on to access or use these photos from Laravel A (Like profile pictures for the rest of the projects). All of these projects are running in a single server locally.

How the rest of the projects access the photos of employees from Laravel A?


Solution

  • I already have workaround with this by creating route for photo preview on my Laravel Project A Route::get('/photos/{filename}), returning the image file. And by saving the uploaded photo to the storage public folder of my Project A, other projects can now access the URL like http://projectA.com/photos/filename.jpg.

    Also by creating custom URL in my .env like: IMG_URL=http://projectA.com/photos/ to all my project, I can access it like this env('IMG_URL').filename.jpg