0

I want to access some images to display in a blade file, but they're stored in /storage/app/content/img.

I've come across a few other posts using symbolic links , but their solutions haven't worked for me.

BLADE FILE

<td>
  @if( !empty($entry->{$column['name']}) )
    <a href="storage/app/content/img/filename.jpg">
      <img src="storage/app/content/img/filename.jpg"/>
    </a>
</td>

WHEN I TRIED SYMBOLIC LINKS - ROUTE

Route::get('/img/{filename}', function ($filename)
{
    $path = storage_path() . '/app/content/img/' . $filename;

    if(!File::exists($path)) abort(404);

    $file = File::get($path);
    $type = File::mimeType($path);

    $response = Response::make($file, 200);
    $response->header("Content-Type", $type);
    return $response;
})->name('avatar');

BLADE FILE

<td>
  @if( !empty($entry->{$column['name']}) )
    <a href="/img/filename.jpg">
      <img src="/img/filename.jpg"/>
    </a>
</td>
Casey
  • 536
  • 2
  • 14
  • 28

1 Answers1

-1

I would suggest you use the asset helper:

asset('img/file.png');
Raza Mehdi
  • 923
  • 5
  • 7