title: File Upload to Slim Framework using curl in php
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8941899/failing-to-upload-file-with-curl-in-heroku-php-app">Failing to upload file with curl in heroku php app</a>  </p>
  </blockquote>
  
  
  
  <p>After handling a file upload in php, I am trying to send that file using curl to my rest api which uses Slim Framework. However, $_FILES is always empty once it reaches the function in Slim. </p>
  
  <p>sender.php</p>
  
  <pre><code>if(move_uploaded_file($_FILES['myFile']["tmp_name"], $UploadDirectory . $_FILES['myFile']["name"] ))
  {
      $ch = curl_init();
      $data = array('name' =&gt; 'test', 'file' =&gt; $UploadDirectory . $_FILES['myFile']["name"]);
  
      curl_setopt($ch, CURLOPT_URL, 'http://localhost/slimlocation/upload/');
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  
      curl_exec($ch); 
   }
  </code></pre>
  
  <p>And the function to receive the request in Slim:</p>
  
  <pre><code>$app-&gt;post('/upload/', function() use ($app) {
      if(isset($_FILES)){
  
          // count is always zero
          echo count($_FILES);
  
      }
  });
  </code></pre>
  
  <p>Am I sending the file incorrectly and / or is it possible to do what I am attempting? Any help is appreciated.</p>