Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I've created multiple memory based files like this:

$fp1 = fopen("php://memory", 'rw+');
fputs($fp1, "hello1");
rewind($fp1);

$fp2 = fopen("php://memory", 'rw+');
fputs($fp2, "hello2");
rewind($fp2);

echo stream_get_contents($fp1);
echo stream_get_contents($fp2);

Now I want these files to be uploadable by CURL. I know how to POST multiple files that exists on the disk with $post['file'] = "@large.jpg"; but now my files are in memory.

How to proceed?

share|improve this question
add comment

1 Answer

Afaik there is no way for cURL to access the php:// files. I had a kind of similar problem and i created a memory disk on OS level

Unix:

mkfs -q /dev/ram1 8192
mkdir -p /ramcache
mount /dev/ram1 /ramcache

This way you can still quite easily use a similar construction for php://memory

$fp1 = fopen('/ramcache/somefile1', 'rw+');
$fp2 = fopen('/ramcache/somefile2', 'rw+');

but also pass it as a real file to cURL, without having convert it from php://memory to a real file before passing it to cURL

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.