如何集成和初始化 laravel 5 的文件系统?
how do i intergrate and initialize filesystem of laravel 5?
我遵循了这个步骤https://github.com/GrahamCampbell/Laravel-Flysystem
composer update "graham-campbell/flysystem": "~1.0" DONE
php artisan vendor:publish DONE
我有这个代码
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;
}
我的表格
@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
出现错误:
Class 'App\Http\Controllers\Storage' not found
您需要导入 Storage
class 因为它是门面。
添加:
use Storage;
在控制器的顶部。
例如:
<?php
namespace App\Http\Controllers;
use Storage;
class YourController {
...
}
你也可以这样做:
$disk = \Storage::disk('s3');
意味着你必须在存储前加上 \
我遵循了这个步骤https://github.com/GrahamCampbell/Laravel-Flysystem
composer update "graham-campbell/flysystem": "~1.0" DONE
php artisan vendor:publish DONE
我有这个代码
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;
}
我的表格
@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
出现错误:
Class 'App\Http\Controllers\Storage' not found
您需要导入 Storage
class 因为它是门面。
添加:
use Storage;
在控制器的顶部。
例如:
<?php
namespace App\Http\Controllers;
use Storage;
class YourController {
...
}
你也可以这样做:
$disk = \Storage::disk('s3');
意味着你必须在存储前加上 \