Cant Upload single image

Posted 2 months ago by nhayder

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>
    <input type="file" name="poster" value="">

the form will post data to controller function

// linke this
<form action="{{route('articleContentStore', $article->id)}}" method="post" enctype="multipart/form-data">

in my controller i have this method

    public function articleContentStore(Request $request, $id)

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

        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 sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.