I'm creating a basic upload form with different input fields, but once I submit my form I'm getting the error :
Call to a member function storeAs() on null
I checked the problem it could have been and everyone was talking about adding the enctype="multipart/form-data" tag on the form... which is already present, so now I really have no clue about what my error could be...
drive.blade.php :
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Drive') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
<form action="/postForm" enctype="multipart/form-data">
<label for="file">File:</label><br>
<input type="file" id="file" name="file"><br>
<label for="folder_id">Folder ID :</label><br>
<input type="text" id="folder_id" name="folder_id"><br>
<label for="organisation_id">Organisation ID :</label><br>
<input type="text" id="organisation_id" name="organisation_id"><br>
<label for="organisation_type">Organisation type :</label><br>
<input type="text" id="organisation_type" name="organisation_type"><br>
<input type="submit" value="Submit"><br>
</form>
</div>
</div>
</div>
</x-app-layout>
My route : Route::get('postForm', "App\Http\Controllers\FileController@store");
My controller:
public function store(Request $request)
{
$userLogged = Auth::user();
$document = $request->file("file");
// dd($document);
$organisation_type = $request->organisation_type;
$organisation_id = $request->organisation_id;
$folder_id = $request->folder_id;
$path = $document->storeAs('public', "tempName");
return response()->json(["result" => "ok"], 201);
}
The Error Is Showing To me 419 Page Expired Because You Don't Add
@csrf
In Your Blade
Or You Can Add <input value='csrf_token()' hidden>