title: Multipart/form-data using PHP
body: <p>I have written an multipart/form-data html which a user can upload directly to AWS S3.  However, I'm looking to use a PHP fwrite() to create the file to be uploaded.  I generate a csv using PHP when the page loads, and then I want that file to be automatically used for the multipart/form-data upload.   Here is that code:</p>
  
  <pre><code> &lt;form action="https://s3.amazonaws.com/my.data" method="post" enctype="multipart/form-data"&gt;
    &lt;input type="hidden" name="key" value="uploads/${filename}"&gt;
    &lt;input type="hidden" name="AWSAccessKeyId" value="xxxxxxxx"&gt; 
    &lt;input type="hidden" name="acl" value="private"&gt; 
    &lt;input type="hidden" name="success_action_redirect" value="http://thanks.html"&gt;
    &lt;input type="hidden" name="policy" value="xxxxxxxxxx"&gt;
    &lt;input type="hidden" name="signature" value="xxxxxxxxx"&gt;
    &lt;input type="hidden" name="Content-Type" value=""&gt;
    &lt;!-- Include any additional input fields here --&gt;
  
    File to upload to S3: 
    &lt;input name="file" type="file"&gt; 
    &lt;br&gt; 
    &lt;input type="submit" value="Upload File to S3"&gt; 
  &lt;/form&gt; 
  
   &lt;?php
   $email = "testemail@gmail.com";
   $art_fair = 0;
  
  //this is where the creating of the csv takes place
  $cvsData = $email . "," . $art_fair . "\n";
  
  $fp = fopen("formTest.csv","a"); // $fp is now the file pointer to new file to create
  
  if($fp){
  fwrite($fp,$cvsData); // Write information to the file
  fclose($fp); // Close the file
  }
  ?&gt;
  </code></pre>
  
  <p>I'm trying to figure out how to combine these together to make it work.  Thanks!</p>