问题描述
在Laravel 8上
file_get_contents(asset('storage/list.json');
给我:
ErrorException file_get_contents(http:// localhost:8000 / storage / list.json):未能 打开流:HTTP请求失败!
但是:http://localhost:8000/storage/list.json
存在,例如可以通过浏览器访问。
在我的config/filesystem.PHP
上,
'local' => [
'driver' => 'local','root' => storage_path('app'),'permissions' => [
'file' => [
'public' => 0664,'private' => 0600,],'dir' => [
'public' => 0775,'private' => 0700,'public' => [
'driver' => 'local','root' => storage_path('app/public'),'url' => env('APP_URL').'/storage','visibility' => 'public',
PHP artisan storage:link
命令。
我甚至尝试按照filesystem.PHP中的描述手动将文件权限添加到存储文件夹,但没有任何变化。
解决方法
要使用文件时,应使用绝对路径。 file_get_contents()很好。 laravel中有一些文件包装器,但内部都使用file_get_contents()。
尝试
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1 -1 1 0">
<ContentPresenter.Resources>
<DataTemplate DataType="{x:Type system:String}">
<TextBlock Style="{StaticResource ButtonText}" Text="{Binding}"/>
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
如果要从存储文件获取,请尝试
waste = waste.reset_index(drop = True)
请参见https://laravel.com/docs/5.5/helpers#method-resource-path