我刚刚托管了我的Laravel应用程序,当我尝试存储任何文件时,路径被复制到数据库但文件本身无法上传,我尝试更改权限但没有改变。我已经在存储文件夹上有一些图像,它们显示得很好。
storage link
已经创建。
控制器
public function addLeague(Request $request) {
$newLeague = new League();
$newLeague->name = $request->input('name');
if ($request->hasFile('logo')) {
$newLeague->logo = $request->logo->store('images');
}
$newLeague->save();
return redirect('/leagues');
}
文件系统
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "s3", "rackspace"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app/public'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],
];
答案 0 :(得分:0)
可能您的符号链接断开了。要检查这一点,请访问公用文件夹并键入Unable to connect to database: MongoNetworkError: failed to connect to server [mongodb:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongodb mongodb:27017]
Unable to connect to database: MongoNetworkError: failed to connect to server [mongodb:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongodb mongodb:27017]
at NativeConnection.db.on (/app/services/mongoose.service.js:25:19)
at emitOne (events.js:116:13)
at NativeConnection.emit (events.js:211:7)
at process.nextTick (/node_modules/mongoose/lib/connection.js:575:37)
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
以查看存储链接。如果为红色,则必须对其进行修复:
查找链接指向的位置:ls
指向新路径的链接:readlink -v storage