Sending raw binary and data with cURL Sending raw binary and data with cURL curl curl

Sending raw binary and data with cURL


Exactly the same way as you do with other variables.In the end everything is send as "binary", or actually in string representation.

So just do

$content = ob_get_contents();//or file_get_contents() or whatever source$data_upload = array('username' => $username,                  'password' => $password,                  'owner' => $owner,                  'destination' => $pathpda,                  'filename' => $filename,                  'filedata' => $cfile,                 'allkindsofdata' => $content );


The trick is to make your binary string into a stream in memory and then tell curl to upload that stream, using: CURLOPT_INFILE, CURLOPT_INFILESIZE and CURLOPT_UPLOAD. This answer provides the code to do it.