title: tokenmismatchexception on uploading a large file laravel 5
body: <p>I get a token mismatch error when I try uploading a large file in laravel 5. I am using the token field in my form.</p>
  
  <pre><code>TokenMismatchException in VerifyCsrfToken.php line 53:
  </code></pre>
  
  <p>I already tried few methods:</p>
  
  <ol>
  <li>increasing upload_max_filesize and post_max_size.</li>
  <li>changing php.ini file and restarting apache services.</li>
  <li>disabling the csrf middleware for that route, but the file is not fetched in this case !</li>
  </ol>
  
  <p>Here is my view:</p>
  
  <pre><code>&lt;form id="csvform22345" role="form" class="form-horizontal" enctype="multipart/form-data" method="POST" action="{{ URL::to('admin/QC/uploadtomaindbcsv') }}"&gt;
    {!! Form::token() !!}
    {{--&lt;input type="hidden" name="_token" value="{{ csrf_token() }}"&gt;--}}
     &lt;input type="hidden" name="pid" value="{{ $pid }}"&gt;
                                      &lt;div class="row"&gt;
                                          &lt;div class="col-sm-8"&gt;
                                              &lt;label class="control-label"&gt;Select File&lt;/label&gt;
                                              &lt;input id="csvfile2" type="file" name="file2" required class="file-loading"&gt;
                                          &lt;/div&gt;
                                          &lt;div class="col-sm-4"&gt;
                                              &lt;div class="alert alert-info small mar-top"&gt;Only .csv files allowed.&lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/form&gt;
  </code></pre>
  
  <p>Controller function:</p>
  
  <pre><code>    public function upload_to_maindb()
  {
      try
      {
      ini_set('upload_max_filesize', '2G');
      ini_set('post_max_size', '4G');
      ini_set('max_execution_time', '5000000');
      ini_set('max_input_time', '5000000');
      ini_set('memory_limit', '200M');
      //echo "try block" ; die;
      $now = new DateTime();
  
      $timestamp = $now-&gt;format('Y-m-d H:i:s');
      $pid = Input::get('pid');
      $file = Input::file('file2');
          $project = Projects::select('project_type')-&gt;where('project_id',$pid)-&gt;get()-&gt;first();
          $pt = $project-&gt;project_type;
      if($file !='') {
          $pid = Input::get('pid');
          $fp = fopen($file, 'r');
          //echo "its here";
          //die;
          $datas = array();
          unset($datas);
  
          while (($row = fgetcsv($fp)) !== FALSE) {
              $contact['company_name'] = $row[0];
              $contact['website'] = $row[1];
              $contact['contact_name'] = $row[2];
              $contact['first_name'] = $row[3];
              $contact['last_name'] = $row[4];
              $contact['email'] = $row[5];
              $contact['title'] = $row[6];
              $contact['address'] = $row[7];
              $contact['city'] = $row[8];
              $contact['state'] = $row[9];
              $contact['zip_code'] = $row[10];
              $contact['country'] = $row[11];
              $contact['phone_number'] = $row[12];
              $contact['fax_number'] = $row[13];
              $contact['industry'] = $row[14];
              $contact['sub_industry'] = $row[15];
              $contact['revenue'] = $row[16];
              $contact['employees'] = $row[17];
              $contact['data_category'] = $pt;
              /*
              $contact['sic_code'] = $row[18];
              $contact['naics_code'] = $row[19];
              $contact['linkedin_source'] = $row[20];
              */
              $contact['last_updated_via_project_id'] = $pid;
              $datas[] = $contact;
          }
          foreach (array_chunk($datas, 200) as $data) {
              Master_datarecords::insertIgnore($data);
          }
      }
      unset($datas);
      //echo "done"; die;
          $msg= "successfully inserted";
      }
      catch(\Exception $e)
          {
              $msg = "some error occured, please check the file.";
          }
  
      $approved_projects= array();
      $pids= array();
      $i=0;
      $projstat = ProjectuserHelpers::GetProjectStatusId("approved");
      $projects_object=Projects::where('project_status',$projstat)-&gt;get();
      if(!($projects_object-&gt;isEmpty())) {
          $projects = $projects_object-&gt;toArray();
          foreach ($projects as $val) {
              $approved_projects[$i]['pid'] = $val['project_id'];
              $approved_projects[$i]['projectname'] = $val['project_name'];
              $approved_projects[$i]['record_count'] = Transitional_records::where('fk_project_id', $val['project_id'])-&gt;count();
              $i++;
          }
      }
      return View::make('admin/home_page/QC/QCtomaindb',compact('approved_projects','msg'));
  }
  </code></pre>
  
  <p>I couldn't find anything besides these in the internet. Is there any other solution ?</p>