Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

muuucho's avatar
Level 11

Problems finding files in storage

On my live server, I have a file www.myexample.com/storage/app/public/sample.pdf I try to embedd it in a blade file with this code:

<embed src="{{  \Illuminate\Support\Facades\Storage::url($invoice->file) }}" width="100" height="150" alt="pdf"/>

But the pdf doesn't show in my browser. When I inspect the page in Chrome it shows:

<embed src="https://myexample.com/storage/app/public/sample.pdf" width="100" height="150" alt="pdf"/>

So, what is wrong here, the path seems correct to me.

0 likes
4 replies
LaryAI's avatar
Level 58

The issue you're encountering is due to the incorrect URL path being generated for the file stored in the storage/app/public directory. In Laravel, files stored in the storage/app/public directory should be accessed via the public/storage URL, not directly from storage/app/public.

To resolve this, you need to ensure that the symbolic link between storage/app/public and public/storage is correctly set up. You can create this symbolic link by running the following Artisan command:

php artisan storage:link

This command will create a symbolic link from public/storage to storage/app/public, allowing you to access your files via the correct URL.

Next, you should update your Blade template to use the correct path. The Storage::url method will generate the correct URL for files stored in the public disk. Ensure that your file is stored in the public disk and that you are using the correct path.

Here's how you can update your Blade template:

<embed src="{{ Storage::url($invoice->file) }}" width="100" height="150" alt="pdf"/>

Make sure that $invoice->file contains the correct relative path to the file within the public disk, for example, sample.pdf.

If your file is stored in storage/app/public/sample.pdf, the correct path to store in the database and use in your Blade template would be sample.pdf.

So, your final Blade template should look like this:

<embed src="{{ Storage::url('sample.pdf') }}" width="100" height="150" alt="pdf"/>

After making these changes, your PDF should be correctly embedded and displayed in the browser.

muuucho's avatar
Level 11

It doesn't work. My config/filesystem:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default filesystem disk that should be used
    | by the framework. The "local" disk, as well as a variety of cloud
    | based disks are available to your application. Just store away!
    |
    */

    'default' => env('FILESYSTEM_DISK', 'local'),

    /*
    |--------------------------------------------------------------------------
    | Filesystem Disks
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many filesystem "disks" as you wish, and you
    | may even configure multiple disks of the same driver. Defaults have
    | been set up for each driver as an example of the required values.
    |
    | Supported Drivers: "local", "ftp", "sftp", "s3"
    |
    */

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'throw' => false,
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'url' => env('APP_URL').'/storage/app',
            'visibility' => 'public',
            'throw' => false,
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
            'throw' => false,
        ],       


    ],

    /*
    |--------------------------------------------------------------------------
    | Symbolic Links
    |--------------------------------------------------------------------------
    |
    | Here you may configure the symbolic links that will be created when the
    | `storage:link` Artisan command is executed. The array keys should be
    | the locations of the links and the values should be their targets.
    |
    */

    'links' => [
        public_path('storage') => storage_path('app/public'),
    ],

];

EDIT: And on .env on server i have FILESYSTEM_DISK=public

Snapey's avatar

because you changed this line in config

'url' => env('APP_URL').'/storage/app',

Please or to participate in this conversation.