php - Laravel : Upload multiple image but First image only uploaded -


i using laravel 4.2 , have form upload multiple images

the problem when submit form returns view page , first image uploaded.

can please review code , correct mistake

{{ form::open(array('url'=>'doaddprojectimage', 'files'=>'true', 'method'=>'put', 'class'=>'margin-top-30 width-100per pull-left')) }}   {{ form::file('img[]', array('class'=>'file', 'multiple'=>true)) }}   {{ form::submit('add images project', array('class'=>'btn-success btn pull-left')) }}   {{ form::hidden('pid', session::get('insid')) }}   {{ form::close() }} 

and controller

public function doaddprojectimage()     {         $proid = input::get('pid');          $projectimages = new projectsimages();         $files = input::file('img');         foreach($files $file) {             $destination_path = 'images/projects/';             $filename = str_random(6) . '_' . $file->getclientoriginalname();             $file->move($destination_path, $filename);              $projectimages->image = $filename;             $projectimages->image_id = $proid;             $projectimages->save();         }          return redirect::to('admin/view-project');     } 

after research found 'multiple'=>true mistake should multiple

so input field be

{{ form::file('img[]', array('class'=>'file', 'multiple')) }} 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -