mardi 4 octobre 2016

Upload Video and Thumbnail in Laravel 5.1

i totally newbie in laravel development. i have few text filed along with 1 video upload and thumbnail upload feature. I can save all those data into DB but i am stuck with video and Thumnail/ image upload.

Here is my controller code

 public function save( Request $request)

{




    $post = $request->all();
    //            var_dump($post);
     $v = \Validator::make($request->all(),
       [

           'title' => 'required',
           'category' => 'required',
           'description' => 'required',
           'price' => 'required',
       ]


       );

    if($v->fails())
    {
        return redirect()->back()->withErrors($v->errors());
    }

    else
    {
        $data = array(

            'title' => $post['title'],
            'category' => $post['category'],
            'partner' => $post['partner'],
            'description' => $post['description'],
            'published' => $post['published'],
            'featured' => $post['featured'],
            'price' => $post['price'],
            'discount' => $post['discount'],
            //'file' => $post['file'],
            'file' => "file",
            //'thumbnail' => $post['thumbnail'],
           'thumbnail' => "thumbnail",





        );
        $i=DB::table('items')->insert($data);
        if($i>0)
        {
            \Session::flash('message','new Item Saved');
            return redirect('itemindex');
        }
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire