title: PHP Curl Proxy, how to define $_FILES['foo']['name']
body: <p>I'm using CURL to make a PHP Proxy that forward a multipart form.<br>
  The form have an input type="file".</p>
  
  <p>The proxy receive the following data:</p>
  
  <pre><code>array
    'foo' =&gt; 
      array
        'name' =&gt; string 'wt.jpg' (length=6)
        'type' =&gt; string 'image/jpeg' (length=10)
        'tmp_name' =&gt; string '/tmp/phpoIvraK' (length=14)
        'error' =&gt; int 0
        'size' =&gt; int 7427
  </code></pre>
  
  <p>So I'm expecting the page at the end to receive the same array (except for the tmp_name)
  Right now I receive this:</p>
  
  <pre><code>'foo' =&gt;
     array
       'name' =&gt; 'phpoIvraK'
       'type' =&gt; 'image/jpeg'
       'tmp_name' =&gt; '/tmp/php5ZhCwy'
       'error' =&gt; 0
       'size' =&gt; 7427
  </code></pre>
  
  <p>As you can see, the name is now the tmp_name that the proxy is receiving, so the original filename is lost.</p>
  
  <p>Here's the PHP Code:</p>
  
  <pre><code>$arrFields = $_POST;
  foreach($_FILES as $k =&gt; $file)
      $arrFields[$k] = '@' . $file['tmp_name'] . ';type=' . $file['type'];
  
  curl_setopt($ressource, CURLOPT_POSTFIELDS, $arrFields);
  </code></pre>
  
  <p>Ps.: I know I could make a new variable, but the goal here is to respect the variable format, and make the usage of the proxy as transparent as possible for the person that'll use it.</p>
  
  <p>Is it me or the only solution would be to rename the tmp file in the /tmp before resending it ? That looks a bit silly to me ...</p>
  
  <pre><code>$arrFields = $_POST;
  foreach($_FILES as $k =&gt; $file){
      move_uploaded_file($file['tmp_name'], $file['name']);
      $arrFields[$k] = '@' . $file['name'] . ';type=' . $file['type'];
  }
  curl_setopt($ressource, CURLOPT_POSTFIELDS, $arrFields);
  </code></pre>