【发布时间】:2017-12-21 07:04:17
【问题描述】:
您好,我在 laravel 中遇到了问题。
我想为一些东西(xls、图像、pdf 等)创建私有存储。 在 storage/app/public 目录中一切正常,但我不想要它,我想要我的目录,如 storage/app/products/{id}/
先看看我的代码:
文件系统.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'productions' => [
'driver' => 'local',
'root' => storage_path('app/productions'),
'visibility' => 'private',
],
我创建了新的数组“产品”
ProductionController.php
public function file()
{
return '<img src="'.Storage::disk('productions')->url('7/2.png').'">';
}
web.php(路由)
Route::group([
'middleware'=>'roles',
'roles'=>['Administrator','Prefabrykacja','Dyrektor Prefabrykacji']
], function () {
Route::get('/Produkcja',[
'uses'=>'ProductionController@index',
'as'=>'production.index']);
Route::post('/Produkcja/create',[
'uses'=>'ProductionController@create',
'as'=>'production.create']);
Route::get('/Produkcja/file',[
'uses'=>'ProductionController@file',
'as'=>'production.file']);
});
如果我回来
return '<img src="'.Storage::disk('productions')->url('7/2.png').'">';
或者
return '<img src="'.Storage::disk('local')->url('7/2.png').'">';
结果是一样的。这两行都从 storage/app/public/7/2.png 返回图像将不显示图像 storage/app/products/7/2.png
如何显示我的产品文件夹中的图像并将资源限制为指定角色?
问候
【问题讨论】:
标签: php laravel laravel-5.4