laravel - Save data of input files multiple -


i'm trying save list of files in post not save relationship.

i want save first post , add images inserted.

class savedata extends componentbase {     public function onsubmitcontact() {         /*          * field: <input type="file" name="files[]" id='files' multiple="true"/>          */         $files = input::file('files');          $modelfiles = new mymodetosave;         $modelrelation = new modeltorelation;          foreach($files $file):             $modelfiles->data = $file;             $modelfiles->save();         endforeach;          $modelrelation->title = post('title');         /* more fields */         $modelrelation->save();          $modelrelation->files()->add($modelfiles);     } } 

tanks code cms october

not sure on exact use case, should work:

    //pass model id, , find in function     $model = modeltorelation::find(post('modelid'));     //commit files relations     $model->commitdeferred(post('_session_key'));      foreach($model->files() $file) {         //now can stuff file...or model     } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -