how do i intergrate and initialize filesystem of laravel 5?

14,939

Solution 1

You need to import Storage class because it's a facade.

Add:

use Storage;

at top of your controller.

For example:

<?php

namespace App\Http\Controllers;

use Storage;

class YourController {
   ...
}

Solution 2

you can also do :

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

Means you must prepend \ before the storage

Share:
14,939
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

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

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

    php artisan vendor:publish DONE

    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
    
  • Admin
    Admin about 9 years
    use Storage; use File; use Fileentry; Error: Class 'Fileentry' not found
  • Marcin Nabiałek
    Marcin Nabiałek about 9 years
    @MarlonBuendia So the error is now different so problem with Storage was solved. I don't know what is Fileentry here - is it your custom class or if it's comming from some package.