你好,我在 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',
],
Run Code Online (Sandbox Code Playgroud)
我创建新的数组“作品”
ProductionController.php
public function file()
{
return '<img src="'.Storage::disk('productions')->url('7/2.png').'">';
}
Run Code Online (Sandbox Code Playgroud)
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']); …Run Code Online (Sandbox Code Playgroud)