问题
I have no idea on how to create symbolic link or symlink.
I am working on File system in laravel 5.2.
The document says that i need to create a symbolic link from public/storage to storage/app/public to keep the publicly accessible files in one directory.
How to create that symlink or symbolic link?
Which file or directory should I place that code?
回答1:
App::make('files')->link(storage_path('app/public'), public_path('storage'));
And don't forget to use App after namespace.
回答2:
Run this command:
php artisan storage:link
回答3:
On Shared Server, where one doesn't have ssh access to run
php artisan storage:link this helps me run that from a controller, the if block code section can also be placed in a Service Provider as well as suggested by @shìpu-ahamed
public function displayForm()
{
if(!file_exists(public_path('storage'))) {
\App::make('files')->link(storage_path('app/public'), public_path('storage'));
}
return view('admin.index');
}
回答4:
Added same code but still getting issue. Method link does not exist. currently i am adding link in my controller constructor.
here is code:
public function index()
{
$shots=[];
App::make('files')->link(storage_path('app\public'), public_path('..\public\storage'));
return View::make('adminpages.index',['shots'=>$shots]);
}
来源:https://stackoverflow.com/questions/38045119/how-to-create-symlink-from-public-storage-to-storage-app-public-in-laravel