I'm coding a kind of php proxy, for internar services.
I'm doing a pretty simple use of curl like this:
$ch = curl_init( $url );
//set timeout to infinit
set_time_limit(0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
if ( strtolower($_SERVER['REQUEST_METHOD']) == 'post' ) {
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST) );
}
curl_setopt($ch, CURLOPT_HTTPHEADER, getallheaders());
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
//Request
list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );
$status = curl_getinfo( $ch );
curl_close( $ch );
I need to include also in that curl exec the incoming file. I don't know the filename, just the form input name.
Question
1) How could I include the content of $_FILES in that CURLOPT_POSTFIELDS ? 2) Do I need to specify if it's a binary file ?
Thanks