php - Retrieve uplaoded photo laravel -


so managed upload multiple images need display in page tried code below says "unidentified variable: photo"

<img class="img-responsive" src="/images/{{ $photo->filename }}" > 

here's upload code, updated code.

    route::post('space/add', array('before' => 'auth', function() {   $data = input::all();    $provider_id = auth::user()->id;   $spaces = space::where('provider_id', '=', $provider_id)->get();    $space = new space;   ....   $space->save();     $file = input::file('image');   $provider_email = auth::user()->email;   // $space = space::find($id);    $rules = array(                  'file' => 'required|mimes:png,gif,jpeg'              );               $validator = \validator::make(array('file'=> $file), $rules);              if($validator->passes())              {                foreach(input::file('image') $file)                {                   $ext = $file->guessclientextension(); // (based on mime type)                   $name = $file->getclientoriginalname();                   $filename = md5($name) . '.' .$ext;                   $destinationpath = 'images/' . $provider_email;                   $file = $file->move($destinationpath, $filename);                  $photo              = new image;                  $photo->provider_id = $provider_id;                  $photo->spaces_id   = $space->id;                  $photo->filename    = $filename;                  $photo->path        = $destinationpath;                  $photo->save();                 }               } else{                   //does not pass validation                   $errors = $validator->errors();               }     return redirect::to('user/spaces')->with(array('spaces' => $spaces, 'photo' => $photo)); })); 

you need

return view::make('yourviewname')->with('photo', $photo); 

this in route or controller depending on setup

edit:

you access varaible in user/spaces through $photo = session::get('photo') user/spaces pass variable in with i.e. ->with('photo', $photo)


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -