TokenMismatchException when using Laravel 5.0 FileSystem
I want to pull an image file from some folder, and I'm trying to use the extension method from the FileSystem class that i found in the Laravel Filesystem API in my controller, but I get a TokenMismatchException.
This is what I have in my controller:
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Html\HtmlFacade;
use Illuminate\Filesystem\Filesystem;
use Filesystem;
use Request;
class PageController extends Controller{
$image_extension = extension("C:/somepath/somefile");
return view('display') ->with(compact('image_extension'));
}
you have to put the code inside a method which is also pointed in the routes.php file and when you get to that route (I am guessing POST), the code will execute.
The method extension() should be on a Flysystem object, you can't call it like that.
public function store(Request $request, Flysystem $flysystem)
{
$image = $request->file('name');
// you should probably move the uploaded file somewhere before you can access it. (I believe a good idea would be in the public directory, or to a cloud service like AWS S3)
$imageExtension = $flysystem->extension('path/to/file');
return view('display', compact('imageExtension'));
}