title: Illegal string offset 'name' laravel
body: <p>I'm getting a illegal string offset when I want to edit a value for my table, but it can add a new value when I try to add a new one. If I comment out the <code>form::file</code> part of my form, it can return the <code>view</code> so i'm guessing the problem is somewhere over there.</p>
  
  <pre><code>&lt;div class="col-md-12"&gt;
              &lt;div class="portlet light bordered"&gt;
                  &lt;div class="portlet-body"&gt;
                      &lt;form action="{{ $formIs === 'add' ? route('campus-media.save', $campusId) : route('campus-media.update', [$campusId, $campusMedia-&gt;id]) }}" method="post" class="form-horizontal" enctype="multipart/form-data"&gt;
                      {{ csrf_field() }}
                          &lt;div class="form-body"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label class="control-label col-md-3"&gt;Title&lt;/label&gt;
                                  &lt;div class="col-md-4"&gt;
                                      {!! Form::text('title', $campusMedia-&gt;title, array('class' =&gt; 'form-control', 'placeholder' =&gt; 'Campus Media Title')) !!}                                        
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="form-body"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label class="control-label col-md-3"&gt;Media&lt;/label&gt;
                                  &lt;div class="col-md-4"&gt;
                                      {!! Form::file('media', $campusMedia-&gt;media, array('class' =&gt; 'form-control')) !!}                                
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="form-body"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label class="control-label col-md-3"&gt;Media type&lt;/label&gt;
                                      &lt;div class="col-md-4"&gt;
                                          {!! Form::select('media_type', $fileType, $campusMedia-&gt;media_type,array('placeholder' =&gt; 'Choose media type', 'class' =&gt; 'form-control')) !!}
                                          &lt;span class="help-block"&gt;0: Image, 1: Video, 2: Logo&lt;/span&gt;
                                      &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="form-body"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label class="control-label col-md-3"&gt;Description&lt;/label&gt;
                                  &lt;div class="col-md-4"&gt;
                                      {!! Form::textarea('description', $campusMedia-&gt;description, array('class' =&gt; 'form-control', 'placeholder' =&gt; 'Campus Media Description', 'rows' =&gt; 3)) !!}              
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="form-body"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label class="control-label col-md-3"&gt;Status&lt;/label&gt;
                                      &lt;div class="col-md-4"&gt;
                                          {!! Form::select('status', $status, $campusMedia-&gt;status,array('placeholder' =&gt; 'Choose status', 'class' =&gt; 'form-control')) !!}
                                          &lt;span class="help-block"&gt;0: Inactive, 1: Active&lt;/span&gt;
                                      &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="form-body"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label class="control-label col-md-3"&gt;Tags&lt;/label&gt;
                                  &lt;div class="col-md-4"&gt;
                                      {!! Form::text('tags', $campusMedia-&gt;tags, array('class' =&gt; 'form-control', 'placeholder' =&gt; 'Campus Media Tags')) !!}                                        
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="form-actions"&gt;
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-offset-3 col-md-9"&gt;
                                      &lt;input type="submit" name="save" class="btn btn-primary" value="Save"/&gt;
                                      &lt;a href="{{ route('campus-media.index', $campusId) }}" class="btn btn-default"&gt; Cancel &lt;/a&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>And here is my controller </p>
  
  <pre><code>class CampusMediaController extends Controller
  {
  //
  public function index($campusId)
  {
      $campusMedia = CampusMedia::ofCampus($campusId)-&gt;get();
      $data = [
          'campusMedia'   =&gt; $campusMedia,
          'campusId'      =&gt; $campusId
      ];
  
      return view('campus-media.index', $data);
  }
  
  public function add($campusId)
  {
      $campusMedia = new CampusMedia;
      $data = [
          'campusMedia' =&gt; $campusMedia,
          'campusId'    =&gt; $campusId,
          'fileType'    =&gt; CampusMedia::getMediaType(),
          'status'      =&gt; CampusMedia::getStatus(),
          'formIs'      =&gt; 'add'
      ];
  
      return view('campus-media.form', $data);
  }
  
  public function save(Request $request, $campusId)
  {
      $this-&gt;validation($request);
      $post = $request-&gt;all();
      $fileName = $this-&gt;upload($request, $campusId);
      $campusMedia = $this-&gt;bindToObject($post, $fileName, $campusId);
      $campusMedia-&gt;save();
  
      return redirect()-&gt;route('campus-media.index', $campusId)-&gt;with('message','Item Succesfully Added');
  }
  
  public function edit($campusId, $id)
  {
      $campusMedia = CampusMedia::find($id);
  
      $data = [
          'campusMedia'             =&gt; $campusMedia,
          'campusId'                =&gt; $campusId,
          'fileType'                =&gt; CampusMedia::getMediaType(),
          'status'                  =&gt; CampusMedia::getStatus(),
          'formIs'                  =&gt; 'edit'
      ];
  
      return view('campus-media.form', $data);
  }
  
  public function update(Request $request,$campusId,$id)
  {
      $this-&gt;validation($request);
      $post = $request-&gt;all();
      $fileName = $this-&gt;upload($request, $campusId);
      $campusMedia = $this-&gt;bindToObject($post, $fileName,$campusId,$id);
      $campusMedia-&gt;save();
  
      return redirect()-&gt;route('campus-media.index', $campusId)-&gt;with('message','Item updated Succesfully');
  }
  
  public function upload($request, $campusId)
  {
      $this-&gt;validate($request, [
              'media' =&gt; 'mimes:png,jpeg,mp4,avi,mpeg,flv,m4v'
          ]
      );
  
      if($request-&gt;input('media_type') == 0){
          $type = "image";
      }elseif($request-&gt;input('media_type') == 1){
              $type = "video";
      }else{
          $type = "logo";
      }
  
      $file   = $request-&gt;file('media');
      if(is_null($file))
          return null;
  
      $ext = $file-&gt;getClientOriginalExtension();
  
  
      $fileName    = sprintf('%s-%s-%s.%s',
          $campusId,
          $type,
          time(),
          $ext
      );
  
      $upload      = config('app.upload_path').'/campus/'.$campusId;
      $file-&gt;move($upload,$fileName);
  
      return $fileName;
  }
  
  public function delete($campusId,$id)
  {
      $campusMedia = CampusMedia::find($id);
      $campusMedia-&gt;delete();
  
      return redirect()-&gt;route('campus-media.index', $campusId)-&gt;with('message','Item deleted Succesfully');
  }
  
  private function validation($request){
      $this-&gt;validate($request, [
              'media' =&gt; 'required'
          ]
      );
  }
  
  private function bindToObject($post, $fileName,$campusId,$id=null)
  {
      if(is_null($id)){
          $campusMedia = new CampusMedia;
      } else {
          $campusMedia = CampusMedia::find($id);
      }
  
      $campusMedia-&gt;campus_id = $campusId;
      $campusMedia-&gt;title = $post['title'];
      $campusMedia-&gt;media = $fileName;
      $campusMedia-&gt;media_type = $post['media_type'];
      $campusMedia-&gt;description = $post['description'];
      $campusMedia-&gt;status = $post['status'];
      $campusMedia-&gt;tags = $post['tags'];
  
      return $campusMedia;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I was hoping someone could help me with this, i rather new in upload files.</p>