Wednesday, April 12, 2017

How i can use Store() method to store image in database in laravel 5.2

when ever i fill submit form it give this massage BadMethodCallException in Macroable.php line 74: Method store does not exist.

ArticleController

public function store(Request $request)
{
    $file = $request->file('attach');
    $filename = $file->store('local');
    $article = new Article;
    $article->title = $request->title;
    $article->body = $request->body;
    $article->attachment = $filename;
    $article->save();
    Session::flash('msg','Your data is saved now');
    return back();
}

addarticle.blade.php


<form class="container col-lg-6" action="article" method="post" enctype ="multipart/form-data">

<div class="form-group"></div>
    Title <input type="text"  class="form-control" name="title">
    Body <textarea name="body" id="" class="form-control" cols="30" rows="10">
</textarea>
    <input type="file" name="attach">
    <input type="submit">
</div>

Route

 Route::get('/', function () {
 return view('welcome');
 });
 Route::get('article','ArticleController@index');
 Route::post('article','ArticleController@store');
 Route::get('allarticle','ArticleController@show');



via Muhammed Umar

Advertisement