问题是执行命令
php artisan storage:link
它应该在那个位置(即。
public_path('storage')
).这是默认行为。您可以手动链接到所需位置,如下所示:
ln -s /absolute/path/to/project_root/storage/app/public /absolute/path/to/project_root/public/wanted-name-of-directory
this answer
. 应该是这样的:
-
php artisan make:command CustomStorageLinkCommand
-
然后从新创建的文件中删除所有内容,并使用以下代码:
<?php
namespace App\Console\Commands;
use Illuminate\Foundation\Console\StorageLinkCommand;
class CustomStorageLinkCommand extends StorageLinkCommand
{
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a symbolic link from "public/a" to "storage/app/public"';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
if (file_exists(public_path('a'))) {
return $this->error('The "public/a" directory already exists.');
}
$this->laravel->make('files')->link(
storage_path('app/public'), public_path('a')
);
$this->info('The [public/a] directory has been linked.');
}
}
-
处决
php artisan存储:链接