Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public function store(Request $request)
  2.     {
  3.         Activity::create( $request->all() );
  4.         $imgid = Activity::all()->last();
  5.         if(Input::hasFile('files')){
  6.             foreach(Input::file('files') as $file){
  7.                 $imageName = rand();
  8.                 $imageSur = $file->getClientOriginalExtension();
  9.                 $nameimg = $imageName.'.'.$imageSur;                
  10.                 $file->move(base_path() . '/public/img/', $nameimg);
  11.                 $img = new Image;
  12.                 $img->image_name = $nameimg;
  13.                 $img->activities_id = $imgid->id;
  14.                 $img->save();
  15.                 echo base_path();
  16.             }
  17.         }
  18.  
  19.         return redirect('/activity');
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement