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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community