Support the ongoing development of Laravel.io →
posted 8 years ago
Configuration
Last updated 2 years ago.
0

First of all, take a look at the documentation: https://laravel.com/docs/5.2/filesystem#the-public-disk and File URLs paragraph.

This is intentional behavior.

    public function url($path)
    {
        $adapter = $this->driver->getAdapter();

        if ($adapter instanceof AwsS3Adapter) {
            $path = $adapter->getPathPrefix().$path;

            return $adapter->getClient()->getObjectUrl($adapter->getBucket(), $path);
        } elseif ($adapter instanceof LocalAdapter) {
            return '/storage/'.$path;
        } else {
            throw new RuntimeException('This driver does not support retrieving URLs.');
        }
    }

What I want you to notice is elseif block. When you use a local filesystem, it returns '/storage/'.$path.

Notice that it starts with a slash. This suggests it should be used only for URLs, so that if you have a file in public/storage/tables/config.xml saying http://your-app.com/storage/tables/config.xml in your browser will give you that file. If you want to place a link, eg. in <a href=""> you should say <a href="{{ Storage::url('tables/config.xml') }}">.

If you want to access a file in a storage/app directory inside your app you can use Storage::get('tables/config.xml'), Storage::put('tables/config.xml', $newContent) etc. as described in the documentation.

Hope it helps.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Richard richard Joined 18 Jun 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.