我如何集成和初始化 Laravel 5 的文件系统?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28791325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:02:34  来源:igfitidea点击:

how do i intergrate and initialize filesystem of laravel 5?

phplaravelnamespacesfilesystemslaravel-5

提问by razzbee

i followed this steps https://github.com/GrahamCampbell/Laravel-Flysystem

我按照这个步骤https://github.com/GrahamCampbell/Laravel-Flysystem

composer update "graham-campbell/flysystem": "~1.0" DONE

php artisan vendor:publish DONE

作曲家更新“graham-campbell/flysystem”:“~1.0”完成

php artisan vendor:发布完成

i have this code

我有这个代码

public function store()
    {
      $file = Request::file('images');
      $extension = $file->getClientOriginalExtension();
        Storage::disk('local')->put($file->getFilename().'.'.$extension,                     File::get($file));
      $entry = new Fileentry();
      $entry->mime = $file->getClientMimeType();
      $entry->original_filename = $file->getClientOriginalName();
      $entry->filename = $file->getFilename().'.'.$extension;
   }

my form

我的表格

@extends('app')

@section('content')

<h1>Create New Timelinemeta</h1>
<form method="POST" action="{{ url('timelinemeta/store') }}" enctype="multipart/form-data">
  <input type="hidden" name="_token" value="{{ csrf_token() }}">
  <div class="form-group">
    <label for="">Images</label>
    <input type="file" class="form-control" name="images">
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>
@endsection

having an error:

有错误:

Class 'App\Http\Controllers\Storage' not found

回答by Marcin Nabia?ek

You need to import Storageclass because it's a facade.

您需要导入Storage类,因为它是一个外观。

Add:

添加:

use Storage;

at top of your controller.

在您的控制器顶部。

For example:

例如:

<?php

namespace App\Http\Controllers;

use Storage;

class YourController {
   ...
}

回答by razzbee

you can also do :

你也可以这样做:

$disk = \Storage::disk('s3');

Means you must prepend \ before the storage

意味着您必须在存储之前加上 \