Level 36
$updateContent->poster = $request->file('poster')->store('posters');
not sure what is happening with my code but i was trying to upload poster image for articles
// in blade
<div class="card-footer">
<button type="button" class="btn btn-icon fuse-ripple-ready" aria-label="add person">
<i class="icon icon-folder-multiple-image"></i>
</button>
<input type="file" name="poster" value="">
</div>
the form will post data to controller function
// linke this
<form action="{{route('articleContentStore', $article->id)}}" method="post" enctype="multipart/form-data">
{{csrf_field()}}
in my controller i have this method
public function articleContentStore(Request $request, $id)
{
$request->validate([
'poster' => 'nullable|image|mimes:jpg,png,jpeg,gif|max:5000',
'hide_poster' => 'int:1,0',
'short_description' => 'nullable|string',
'hide_introduction' => 'int:1,0',
'connector' => 'required|string',
'hide_connector' => 'int:1,0',
'description' => 'nullable|string',
'hide_description' => 'int:1,0',
]);
$updateContent = Article::findOrFail($id);
$updateContent->poster = $request->input('poster');
$updateContent->thumbnail = $request->input('thumbnail');
$updateContent->hide_poster = $request->input('hide_poster') ? : 0;
$updateContent->short_description = $request->input('short_description');
$updateContent->hide_introduction = $request->input('hide_introduction') ? : 0;
$updateContent->connector = $request->input('connector');
$updateContent->hide_connector = $request->input('hide_connector') ? : 0;
$updateContent->description = $request->input('description');
$updateContent->hide_description = $request->input('hide_description') ? : 0;
$updateContent->save();
flash('success');
return redirect()->route('articleContent', compact('id'));
}
The post is returning correct data but im getting Null value for poster
return $request; // this is returning bellow
{"_token":"CV8zxIji3HsO3hnD3G4VCtaTeJmcpQo6gGdu8oqT","short_description":"this is the introduction to of the article","hide_introduction":"1","connector":"Read more","hide_connector":"1","description":"this is article full content","hide_description":"1","poster":{}}
poster is empty
Any idea on what is happening
Please or to participate in this conversation.