Question about Curl and File Uploads

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I wrote the following script that uses Curl to mimic submitting a form
with <input type='file'>.  It works well, but for security reasons, I
would like to not have to write the necessary data to a temporary file.
  If anyone could point me in the right direction, that would be great.

-HC :)

  // Write the batch file to a temporary file
  $filename = "batchtemp" . time() . ".tmp";
  // We will use curl to send this file for processing
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_URL, " /");
  curl_setopt($ch, CURLOPT_POSTFIELDS, array("batchFile"=>"@$filename));
  // Write $batchFile to the temporary file.
  if (!$file = fopen($filename, "w")) { echo "Cannot open file
($filename)"; exit; }
  if (fwrite($file, $batchFile) === FALSE) { echo "Cannot write to file
($filename)"; exit; }
  // Send the data
  $txResult = curl_exec($ch);
  // We're done with the temp file, and curl.

Site Timeline