Search code examples
phplaravel-5.5file-storage

Laravel 5.5 - read the images stored in external folder


In my Laravel 5.5 Project, I have saved the images in folder 'public/uploads' and I can read the images too with the URL http://localhost/my_project/public/uploads/77FAk4TSvXbX.jpg. Then I attempted to store the images in 'D:/Uploads' which was successful using the configuration

'local' => [
    'driver' => 'local',
    'root' => 'D:/Uploads'
],

But now I am stuck at retrieving these images. I cannot read the images directly as in case I could do previously, straight though URL.

Can anyone please help me for this?

Here is the code written to upload images to D:/Uploads

$image  = str_random(12) . "." . $request->image->getClientOriginalExtension();
$request->image->storeAs('', $image);

Solution

  • Write 'visibility' => 'public', in the configuration file inside local array and then try following code:

    $contents = Storage::get('path_to_file');
    

    It should work. If you still have any issue let me know.