I'm using a 3rd party PHP class to access an API, it has got the following code:
$fh = fopen('php://memory', 'w+');
fwrite($fh, $xml);
rewind($fh);
$ch = curl_init($req->to_url() );
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $fh);
On the last line, i.e this one:
curl_setopt($ch, CURLOPT_INFILE, $fh);
I'm getting the error:
Warning: curl_setopt() [function.curl-setopt]: cannot represent a stream of type MEMORY as a STDIO FILE*
What am I doing wrong?
Your Memory File Handle is only open for writing (w+). Add reading, e.g. try to set rw+
for the file handle.
An alternative would be to use php://temp
instead of memory. That would write to a temporary file if there isn't enough memory available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With