I’ve discovered that php supports a special “php://memory” path to create a temporary memory stream with fopen(). Is there any way to get a unique path that maps to this stream via the file system?
I probably worded that wrong but what I need to do is use curl to upload a file via POST, and the only way that I’ve gotten this to work is by addressing a file with "@".filename in the post arguments.
However, the thing is I already have the file contents in a variable and don’t want to write it to a file on disk just to have curl read it from disk and then delete the file. Can I pass something like “php://memory/identifier” to identify the memory stream while it is open?
No.
php://memoryis a buffer located in memory only, and thus is not mapped into the file system.If you wanted to have a path to pass to curl that was memory-based, you’d need to create an actual ramdisk mount on your server that you could write to from PHP and then pass that path to cURL.