1

I'm using cURL with PHP. I need to post the content of a buffer so that the server sees it as a file upload. This what I tried:

$post_data['Filename'] = "foo.wav";

$post_data['File'] =  $filedata;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $myurl);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

curl_close($ch);

This sends the buffer content as a normal form field and not as a file upload. The examples for uploading a file assume the file was not already read in memory and require the file path to be set with a '@' in front. How can I upload my buffer as though it was a file, without writing my buffer to disk of course?

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.