I'm trying to send in POST a raw binary file together with some other data using cURL. Basically, I did that:
//Here i create the CURLFile
$cfile = new CURLFile($fullpath,'application/xml', $filename);
//Data to upload (including the file)
$data_upload = array('username' => $username,
'password' => $password,
'owner' => $owner,
'destination' => $pathpda,
'filename' => $filename,
'filedata' => $cfile);
//Upload
$ch_upload = curl_init($urlws.$e_upload);
curl_setopt($ch_upload, CURLOPT_POST,true);
curl_setopt($ch_upload, CURLOPT_POSTFIELDS, $data_upload);
curl_setopt($ch_upload, CURLOPT_RETURNTRANSFER, true);
$response_upload = curl_exec($ch_upload);
curl_close($ch_upload);
Everything worked fine. Except that now I want my file to be just binary data and not a real file on disk. Also, I need to send the other data in the request! Does anyone knows how to do that? I looked up in Google but I wasn't able to find a way to do both, sending the raw binary file and the other data. Thanks!
UPDATE To further clarify my question, I don't need to just send random binary data, rather a file whose content comes from ob_get_contents() (for example) so it's not a a physical file on disk. If i just replace the CURLfile to send the binary file data with the "filedata" variable, it simply doesn't work. The web service doesn't recognize the file. Maybe there's a way to create a CURLfile without pointing to a real file.
FILEit is stored on a disk in afolder, otherwise it is just content. File and filesystems are just paradigms on how data is stored, you just want to send the content which is nothing different than sending a username string.