|  | Posted by HC on 05/15/06 17:35 
OK, last time I posted, I must have been totally unclear :)  Hopefully this clears things up:
 
 I wrote the following script that uses Curl to mimic submitting a form
 over SSL 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, "https://www.example.com/");
 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; }
 fclose($file);
 // Send the data
 $txResult = curl_exec($ch);
 // We're done with the temp file, and curl.
 unlink($filename);
 curl_close($ch);
 [Back to original message] |