title: Laravel 4 TokenMissMatchException with Plupload
body: <p>I'm trying to upload files with Plupload but I always get TokenMissMatchException. </p>
  
  <pre><code>// Route
  Route::post("/posts/gallery", "PostsController@uploadGallery");
  // Controller action
      public function uploadGallery(){
          $file = Input::file('file');
          $destinationPath = public_path() . '/imgs';
          $extension = $file-&gt;getClientOriginalExtension();
          $filename = "post-" . str_random(12) . "." . $extension;
  
          $inFile = $file-&gt;getRealPath();
          $outFile = public_path() . "/imgs/" . $filename;
  
          $image = new Imagick($inFile);
          $image-&gt;thumbnailImage(550, 0);
          if($image-&gt;writeImage($outFile)){
              return Response::json(["response" =&gt; "ok", "img" =&gt; $filename]);
          }else{
              return Response::json(["response" =&gt; "error"]);
          }
      }
  </code></pre>
  
  <p>This is my attempt to fix this. I tried to add <code>_token</code> to request but it's not picking it up:</p>
  
  <pre><code>$("#uploader").pluploadQueue({
              runtimes : 'html5,flash,silverlight,html4',
              url : "{{ URL::action('PostsController@uploadGallery') }}",
              chunk_size: '1mb',
              rename : true,
              dragdrop: true,
  
              filters : {
                  max_file_size : '3mb',
                  mime_types: [
                      {title : "Image files", extensions : "jpg,gif,png"},
                  ]
              },
              resize : {width : 320, height : 240, quality : 90},
              flash_swf_url : "&lt;?php echo public_path() . '/js/Moxie.swf'; ?&gt;",
              silverlight_xap_url : "&lt;?php echo public_path() . '/js/Moxie.xap'; ?&gt;",
              prevent_duplicates: true,
              multipart_params : {
                  "_token" : $("[name=_token]").val()
              }
          });
  </code></pre>
  
  <p>In filters.php I have this:</p>
  
  <pre><code>Route::filter('csrf', function() {
      $token = Request::ajax() ? Request::header('x-csrf-token') : Input::get('_token');
      if (Session::token() != $token){
          throw new Illuminate\Session\TokenMismatchException;
      }
  });
  </code></pre>
  
  <p>Can someone help me with this?</p>
  
  <p>UPDATE:</p>
  
  <p>Html form for uploading files:</p>
  
  <pre><code>&lt;div class="imageGallery"&gt;
      {{ Form::open() }}
          &lt;div id="uploader"&gt;
              &lt;p&gt;Your browser doesn't have Flash, Silverlight or HTML5 support.&lt;/p&gt;
          &lt;/div&gt;
      {{ Form::close() }}
  &lt;/div&gt;
  </code></pre>
  
  <p>// hidden input field</p>
  
  <pre><code>&lt;input type="hidden" value="VJRUpvq92oYxCsNHVBi5TqqkU6I6CQayay6x7L0m" name="_token"&gt;
  </code></pre>