Create a file handler in memory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
johnjohn
Forum Newbie
Posts: 1
Joined: Fri May 25, 2007 9:36 am

Create a file handler in memory

Post by johnjohn »

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
Post Reply