0

Не загружаются файлы в Laravel 5.7.

filisystem.php

    'disks' => [

    'local' => [
        'driver' => 'local',
        'root'   => storage_path('app'),
    ],

    'public' => [
        'driver'     => 'local',
        'root'       => storage_path('app/public'),
        'visibility' => 'public',
    ],
]

Контролер загрузки файлов:

    public function channelAvatar(Request $request, Channel $channel)
{
    // validate
    $this->validate($request, [
        'photo' => ['required', 'image', Rule::dimensions()->minWidth(250)->minHeight(250)->ratio(1 / 1)],
    ]);

    // fill variables
    $filename = time() . str_random(16) . '.png';
    $image = Image::make($request->file('photo')->getRealPath());
    $folder = 'channels/avatars';

    // crop it
    $image = $image->resize(250, 250);

    // optimize it
    $image->encode('png', 60);

    // upload it
    Storage::put($folder . '/' . $filename, $image);
    $imageAddress = $this->webAddress() . $folder . '/' . $filename;

    // delete the old avatar
    Storage::delete('channels/avatars/' . str_after($channel->avatar, 'channels/avatars/'));

    // update channel's avatar
    $channel->update([
        'avatar' => $imageAddress,
    ]);
    $this->putChannelInTheCache($channel);

    return $imageAddress;
}

В логе эта ошибка:

local.ERROR: Driver [] is not supported. {"userId":1,"email":"[email protected]","exception":"[object] (InvalidArgumentException(code: 0): Driver [] is not supported. at //vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php:127)

В чем ошибка и как ее исправить?

2
  • попробуйте явно указывать диск: Storage::disc('public')->put($folder . '/' . $filename, $image) 18 фев 2019 в 5:35
  • а что в файле .env?
    – n.osennij
    18 фев 2019 в 10:30

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Посмотрите другие вопросы с метками или задайте свой вопрос.