Laravel在我的刀片表单上使用enctype="multipart/form-data"标签时"Call to a member function storeAs() on null"



我正在创建一个具有不同输入字段的基本上传表单,但一旦提交表单,我就会收到错误:

在空上调用成员函数storeAs((

我检查了可能存在的问题,每个人都在讨论添加enctype="多部分/形式数据";表单上的标签…已经存在了,所以现在我真的不知道我的错误可能是什么…

drive.blade.hp:

<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>

我的路线:Route::get('postForm', "AppHttpControllersFileController@store");

我的控制器:

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);
}

错误显示给我419页由于您没有添加而过期

刀片中的@csrf

或者您可以添加<input value='csrf_token()' hidden>

相关内容

最新更新