title: Uploading files in Slim 2
body: <p>I'm trying to upload a file using Slim 2. But I'm lost for how I can access the $_FILES[] parameter. </p>
  
  <p>I have the following AJAX call to index.php from JQuery.</p>
  
  <pre><code> $("form[name='photo_upload']").on('submit',(function() {
      var location='{{site.uri.image}}/profile/{{bio.user_id}}';
      var fd=new FormData(this);
      fd.append('id',{{bio.user_id}});
      fd.append('loc',location);
      $.ajax({
          'url': '{{site.uri.public}}/bio?id={{user.id}}&amp;action=update',
          'type': "POST",
          'data': fd,                
          'cache': false,
          'processData': false,
          'success': function(data){
              var new_loc='{{site.uri.image}}/profile/'+data['photo_loc'];
              $("#frame").attr("src",new_loc);
              $('.editbox.'+cls).addClass("hidden");
          }
      });
  }));
  </code></pre>
  
  <p>Now I pickup the request with the following function in index.php using Slim 2.</p>
  
  <pre><code>$app-&gt;post('/bio/?', function () use ($app) {    
  
          $id=$app-&gt;request-&gt;params('id');
          $loc=$app-&gt;request-&gt;params('loc');
          $file = $_FILES['image'];
          $controller = new TE\UserController($app);
          $controller-&gt;updateUserPhoto($id, $file, $loc);
          $ret=$controller-&gt;getUserBio($id, 'photo');
          error_log($ret);
          echo json_encode(array('photo_loc' =&gt; $ret));      
  });
  </code></pre>
  
  <p>and get the following error</p>
  
  <pre><code>Undefined index: image
  </code></pre>
  
  <p>at the line containing</p>
  
  <pre><code>$file = $_FILES['image'];
  </code></pre>
  
  <p>on the above code.</p>
  
  <p>I would really appreciate some help on this.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I get the following when I var_dump[$_FILES].</p>
  
  <pre><code>array(1) { ["image"]=&gt; array(5) { ["name"]=&gt; string(8) "1a_1.PNG" ["type"]=&gt; string(9) "image/png" ["tmp_name"]=&gt; string(24) "C:\xampp\tmp\php585C.tmp" ["error"]=&gt; int(0) ["size"]=&gt; int(19762) } }
  </code></pre>
  
  <p>It seems $_FILES['image'] and all the file info are there. </p>
  
  <p>I even did an </p>
  
  <pre><code>isset($_FILES['image'])
  </code></pre>
  
  <p>to check and even that returned true.</p>
  
  <p>So why cant I retrieve if its already there?</p>