I know of posting only binary:
$file_contents = file_get_contents("http://example.org/image.jpg");
curl_setopt($ch, CURLOPT_POSTFIELDS, $file_contents);
as well as posting text along with binary from a file on disk:
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"name" => "peter",
"msg" => "hello",
"foo" => "@file/on/disk/image.jpg"
));
But what I can't figure out is how to post binary data directly from a variable (e.g. $file_contents) along with plain text key-value pairs. Is this possible with curl?
The reason I'm asking is that I'm using the facebook API to create events and need to upload an image along the rest of the event data. Because I'm getting the images from the internet it would be great if I didn't have to save them on disk before posting, then delete them from disk, but instead do the post directly with the data from file_get_contents() saved in a php variable.
tempnam()will do that for you.