Create a file handler in memory
Posted: Fri May 25, 2007 9:55 am
Hi,
I need to upload a text file via CURL to an FTP server. The file contains important data that i don't want to be saved in my filesystem, even temporarily.
So i have to create a file on the fly (in memory???), put the data i want in it, do whatever i need to do with it and then discard it.
I can upload an existing file without a problem. What i can not do is write the data i need into it while it's opened.
Curl needs an open file handler when doing FTP uploads.
curl_setopt($ch, CURLOPT_INFILE, $infile);
However, once the file is open, it can not be modified (e.g have an empty template, open it and write to it). No other stream handler works with it.
How can this be achieved?
Thanks,
John
I need to upload a text file via CURL to an FTP server. The file contains important data that i don't want to be saved in my filesystem, even temporarily.
So i have to create a file on the fly (in memory???), put the data i want in it, do whatever i need to do with it and then discard it.
I can upload an existing file without a problem. What i can not do is write the data i need into it while it's opened.
Curl needs an open file handler when doing FTP uploads.
curl_setopt($ch, CURLOPT_INFILE, $infile);
However, once the file is open, it can not be modified (e.g have an empty template, open it and write to it). No other stream handler works with it.
How can this be achieved?
Thanks,
John